id
stringlengths
52
144
question
stringlengths
3
879
target
stringlengths
1
248
answers
sequence
ctxs
list
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_0_0
import android.net.Uri;
package ru.a402d.rawbtapidemo;
[ "package ru.a402d.rawbtapidemo;\n" ]
[ { "title": "in_file#lines#0.5", "text": "\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "android net Uri android os Bundle android view MenuItem android view View android widget AdapterView android widget ArrayAdapter android widget Spinner android widget Toast androidx annotation Nullable androidx appcompat widget Toolbar com google android material appbar CollapsingToolbarLayout java util ArrayList rawbt api AppCompatWithRawbtActivity rawbt api attributes AttributesBarcode rawbt api attributes AttributesString rawbt api attributes AttributesImage rawbt api command CommandBarcode rawbt api RawbtPrintJob rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_E", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_2_15
import android.os.Bundle; import android.view.MenuItem; package ru.a402d.rawbtapidemo; import android.
net.Uri;
[ "net.Uri;\n" ]
[ { "title": "in_file#lines#0.5", "text": "import android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();", "score": 1 }, { "title": "in_file#lines#0.75", "text": "import android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "import android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_sp", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "android os Bundle android view MenuItem android view View android widget AdapterView android widget ArrayAdapter android widget Spinner android widget Toast androidx annotation Nullable androidx appcompat widget Toolbar com google android material appbar CollapsingToolbarLayout java util ArrayList rawbt api AppCompatWithRawbtActivity rawbt api attributes AttributesBarcode rawbt api attributes AttributesString rawbt api attributes AttributesImage rawbt api command CommandBarcode rawbt api RawbtPrintJob rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 set", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_3_0
import android.view.MenuItem; import android.view.View; import android.net.Uri;
import android.os.Bundle;
[ "import android.os.Bundle;\n" ]
[ { "title": "in_file#lines#0.5", "text": "import android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }", "score": 1 }, { "title": "in_file#lines#0.75", "text": "import android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "import android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "android view MenuItem android view View android widget AdapterView android widget ArrayAdapter android widget Spinner android widget Toast androidx annotation Nullable androidx appcompat widget Toolbar com google android material appbar CollapsingToolbarLayout java util ArrayList rawbt api AppCompatWithRawbtActivity rawbt api attributes AttributesBarcode rawbt api attributes AttributesString rawbt api attributes AttributesImage rawbt api command CommandBarcode rawbt api RawbtPrintJob rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setH", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\n", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_4_7
import android.view.View; import android.widget.AdapterView; import android.net.Uri; import android.os.Bundle; import
android.view.MenuItem;
[ "android.view.MenuItem;\n" ]
[ { "title": "in_file#lines#0.5", "text": "import android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return", "score": 1 }, { "title": "in_file#lines#0.75", "text": "import android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "import android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelect", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "android view View android widget AdapterView android widget ArrayAdapter android widget Spinner android widget Toast androidx annotation Nullable androidx appcompat widget Toolbar com google android material appbar CollapsingToolbarLayout java util ArrayList rawbt api AppCompatWithRawbtActivity rawbt api attributes AttributesBarcode rawbt api attributes AttributesString rawbt api attributes AttributesImage rawbt api command CommandBarcode rawbt api RawbtPrintJob rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_5_0
import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.os.Bundle; import android.view.MenuItem;
import android.view.View;
[ "import android.view.View;\n" ]
[ { "title": "in_file#lines#0.5", "text": "import android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(", "score": 1 }, { "title": "in_file#lines#0.75", "text": "import android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "import android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "android widget AdapterView android widget ArrayAdapter android widget Spinner android widget Toast androidx annotation Nullable androidx appcompat widget Toolbar com google android material appbar CollapsingToolbarLayout java util ArrayList rawbt api AppCompatWithRawbtActivity rawbt api attributes AttributesBarcode rawbt api attributes AttributesString rawbt api attributes AttributesImage rawbt api command CommandBarcode rawbt api RawbtPrintJob rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\n", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_6_0
import android.widget.ArrayAdapter; import android.widget.Spinner; import android.view.MenuItem; import android.view.View;
import android.widget.AdapterView;
[ "import android.widget.AdapterView;\n" ]
[ { "title": "in_file#lines#0.5", "text": "import android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": "import android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "import android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "android widget ArrayAdapter android widget Spinner android widget Toast androidx annotation Nullable androidx appcompat widget Toolbar com google android material appbar CollapsingToolbarLayout java util ArrayList rawbt api AppCompatWithRawbtActivity rawbt api attributes AttributesBarcode rawbt api attributes AttributesString rawbt api attributes AttributesImage rawbt api command CommandBarcode rawbt api RawbtPrintJob rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add B", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\n", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_7_7
import android.widget.Spinner; import android.widget.Toast; import android.view.View; import android.widget.AdapterView; import
android.widget.ArrayAdapter;
[ "android.widget.ArrayAdapter;\n" ]
[ { "title": "in_file#lines#0.5", "text": "import android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": "import android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "import android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "android widget Spinner android widget Toast androidx annotation Nullable androidx appcompat widget Toolbar com google android material appbar CollapsingToolbarLayout java util ArrayList rawbt api AppCompatWithRawbtActivity rawbt api attributes AttributesBarcode rawbt api attributes AttributesString rawbt api attributes AttributesImage rawbt api command CommandBarcode rawbt api RawbtPrintJob rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_E", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_8_0
import android.widget.Toast; import android.widget.AdapterView; import android.widget.ArrayAdapter;
import android.widget.Spinner;
[ "import android.widget.Spinner;\n" ]
[ { "title": "in_file#lines#0.5", "text": "import android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinter", "score": 1 }, { "title": "in_file#lines#0.75", "text": "import android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "import android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelect", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "android widget Toast androidx annotation Nullable androidx appcompat widget Toolbar com google android material appbar CollapsingToolbarLayout java util ArrayList rawbt api AppCompatWithRawbtActivity rawbt api attributes AttributesBarcode rawbt api attributes AttributesString rawbt api attributes AttributesImage rawbt api command CommandBarcode rawbt api RawbtPrintJob rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\n", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_9_7
import androidx.annotation.Nullable; import android.widget.ArrayAdapter; import android.widget.Spinner; import
android.widget.Toast;
[ "android.widget.Toast;\n" ]
[ { "title": "in_file#lines#0.5", "text": "\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "androidx annotation Nullable androidx appcompat widget Toolbar com google android material appbar CollapsingToolbarLayout java util ArrayList rawbt api AppCompatWithRawbtActivity rawbt api attributes AttributesBarcode rawbt api attributes AttributesString rawbt api attributes AttributesImage rawbt api command CommandBarcode rawbt api RawbtPrintJob rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth set", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_11_35
import androidx.appcompat.widget.Toolbar; import android.widget.Toast; import androidx.annotation.Nullable
;
[ ";\n" ]
[ { "title": "in_file#lines#0.5", "text": "import androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new Array", "score": 1 }, { "title": "in_file#lines#0.75", "text": "import androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "import androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelect", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "androidx appcompat widget Toolbar com google android material appbar CollapsingToolbarLayout java util ArrayList rawbt api AppCompatWithRawbtActivity rawbt api attributes AttributesBarcode rawbt api attributes AttributesString rawbt api attributes AttributesImage rawbt api command CommandBarcode rawbt api RawbtPrintJob rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_12_7
import com.google.android.material.appbar.CollapsingToolbarLayout; import androidx.annotation.Nullable; import
androidx.appcompat.widget.Toolbar;
[ "androidx.appcompat.widget.Toolbar;\n" ]
[ { "title": "in_file#lines#0.5", "text": "\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.On", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "com google android material appbar CollapsingToolbarLayout java util ArrayList rawbt api AppCompatWithRawbtActivity rawbt api attributes AttributesBarcode rawbt api attributes AttributesString rawbt api attributes AttributesImage rawbt api command CommandBarcode rawbt api RawbtPrintJob rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_14_42
import java.util.ArrayList; import androidx.appcompat.widget.Toolbar; import com.google.android.material.appbar.
CollapsingToolbarLayout;
[ "CollapsingToolbarLayout;\n" ]
[ { "title": "in_file#lines#0.5", "text": "\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "java util ArrayList rawbt api AppCompatWithRawbtActivity rawbt api attributes AttributesBarcode rawbt api attributes AttributesString rawbt api attributes AttributesImage rawbt api command CommandBarcode rawbt api RawbtPrintJob rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_16_12
import rawbt.api.AppCompatWithRawbtActivity; import com.google.android.material.appbar.CollapsingToolbarLayout; import java.
util.ArrayList;
[ "util.ArrayList;\n" ]
[ { "title": "in_file#lines#0.5", "text": "\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "rawbt api AppCompatWithRawbtActivity rawbt api attributes AttributesBarcode rawbt api attributes AttributesString rawbt api attributes AttributesImage rawbt api command CommandBarcode rawbt api RawbtPrintJob rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_18_17
import rawbt.api.attributes.AttributesBarcode; import rawbt.api.attributes.AttributesString; import java.util.ArrayList; import rawbt.api.
AppCompatWithRawbtActivity;
[ "AppCompatWithRawbtActivity;\n" ]
[ { "title": "in_file#lines#0.5", "text": "import rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": "import rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "import rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "rawbt api attributes AttributesBarcode rawbt api attributes AttributesString rawbt api attributes AttributesImage rawbt api command CommandBarcode rawbt api RawbtPrintJob rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 set", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_19_7
import rawbt.api.attributes.AttributesString; import rawbt.api.attributes.AttributesImage; import rawbt.api.AppCompatWithRawbtActivity; import
rawbt.api.attributes.AttributesBarcode;
[ "rawbt.api.attributes.AttributesBarcode;\n" ]
[ { "title": "in_file#lines#0.5", "text": "import rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private", "score": 1 }, { "title": "in_file#lines#0.75", "text": "import rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "import rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "rawbt api attributes AttributesString rawbt api attributes AttributesImage rawbt api command CommandBarcode rawbt api RawbtPrintJob rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_20_28
import rawbt.api.attributes.AttributesImage; import rawbt.api.command.CommandBarcode; import rawbt.api.AppCompatWithRawbtActivity; import rawbt.api.attributes.AttributesBarcode; import rawbt.api.attributes.
AttributesString;
[ "AttributesString;\n" ]
[ { "title": "in_file#lines#0.5", "text": "import rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": "import rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "import rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "rawbt api attributes AttributesImage rawbt api command CommandBarcode rawbt api RawbtPrintJob rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add B", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_21_13
import rawbt.api.command.CommandBarcode; import rawbt.api.RawbtPrintJob; import rawbt.api.attributes.AttributesBarcode; import rawbt.api.attributes.AttributesString; import rawbt.
api.attributes.AttributesImage;
[ "api.attributes.AttributesImage;\n" ]
[ { "title": "in_file#lines#0.5", "text": "import rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList =", "score": 1 }, { "title": "in_file#lines#0.75", "text": "import rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 =", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "import rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "rawbt api command CommandBarcode rawbt api RawbtPrintJob rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_22_7
import rawbt.api.RawbtPrintJob; import static rawbt.api.Constant.*; import rawbt.api.attributes.AttributesString; import rawbt.api.attributes.AttributesImage; import
rawbt.api.command.CommandBarcode;
[ "rawbt.api.command.CommandBarcode;\n" ]
[ { "title": "in_file#lines#0.5", "text": "import rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": "import rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "import rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "rawbt api RawbtPrintJob rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri H", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_23_13
import static rawbt.api.Constant.*; import rawbt.api.attributes.AttributesImage; import rawbt.api.command.CommandBarcode; import rawbt.
api.RawbtPrintJob;
[ "api.RawbtPrintJob;\n" ]
[ { "title": "in_file#lines#0.5", "text": "import static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEM", "score": 1 }, { "title": "in_file#lines#0.75", "text": "import static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "import static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "rawbt api Constant DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_24_14
import rawbt.api.command.CommandBarcode; import rawbt.api.RawbtPrintJob; import static
rawbt.api.Constant.*;
[ "rawbt.api.Constant.*;\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "DemoSdkActivity attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add B", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AppCompatWithRawbtActivity RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_27_13
private final RawbtPrintJob attrJob = new RawbtPrintJob(); public class
DemoSdkActivity extends AppCompatWithRawbtActivity {
[ "DemoSdkActivity extends AppCompatWithRawbtActivity {\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPL", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "attrJob Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "RawbtPrintJob RawbtPrintJob Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_29_18
// ----------------------------------------- public class DemoSdkActivity extends AppCompatWithRawbtActivity { private final
RawbtPrintJob attrJob = new RawbtPrintJob();
[ "RawbtPrintJob attrJob = new RawbtPrintJob();\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new Attributes", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "Override onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_33_4
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // -----------------------------------------
@Override
[ "@Override\n" ]
[ { "title": "in_file#lines#0.5", "text": " protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> get", "score": 1 }, { "title": "in_file#lines#0.75", "text": " protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DE", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "onCreate savedInstanceState onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight set", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "Bundle Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onCreate onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_34_28
super.onCreate(savedInstanceState); @Override protected void onCreate(
Bundle savedInstanceState) {
[ "Bundle savedInstanceState) {\n" ]
[ { "title": "in_file#lines#0.5", "text": " super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String", "score": 1 }, { "title": "in_file#lines#0.75", "text": " super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "onCreate savedInstanceState setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri H", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_35_3
setContentView(R.layout.activity_demo_sdk); @Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
[ " super.onCreate(savedInstanceState);\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .set", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "setContentView R layout activity_demo_sdk toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_37_4
Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_demo_sdk);
[ " setContentView(R.layout.activity_demo_sdk);\n" ]
[ { "title": "in_file#lines#0.5", "text": " Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "toolbar findViewById R id toolbar setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 set", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "Toolbar CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_38_8
setSupportActionBar(toolbar); CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout); setContentView(R.layout.activity_demo_sdk);
Toolbar toolbar = findViewById(R.id.toolbar);
[ "Toolbar toolbar = findViewById(R.id.toolbar);\n" ]
[ { "title": "in_file#lines#0.5", "text": " setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.", "score": 1 }, { "title": "in_file#lines#0.75", "text": " setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "setSupportActionBar toolbar toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_39_8
CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout); toolBarLayout.setTitle(getTitle()); setContentView(R.layout.activity_demo_sdk); Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
[ "setSupportActionBar(toolbar);\n" ]
[ { "title": "in_file#lines#0.5", "text": " CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add", "score": 1 }, { "title": "in_file#lines#0.75", "text": " CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "toolBarLayout findViewById R id toolbar_layout toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "CollapsingToolbarLayout Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_40_8
toolBarLayout.setTitle(getTitle()); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar);
CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);
[ "CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n" ]
[ { "title": "in_file#lines#0.5", "text": " toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7", "score": 1 }, { "title": "in_file#lines#0.75", "text": " toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new Attributes", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "toolBarLayout setTitle getTitle getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_41_8
// add back arrow to toolbar setSupportActionBar(toolbar); CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);
toolBarLayout.setTitle(getTitle());
[ "toolBarLayout.setTitle(getTitle());\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "getSupportActionBar getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_44_11
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); // add back arrow to toolbar if
(getSupportActionBar() != null) {
[ "(getSupportActionBar() != null) {\n" ]
[ { "title": "in_file#lines#0.5", "text": " getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.set", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "getSupportActionBar setDisplayHomeAsUpEnabled getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_B", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_45_9
getSupportActionBar().setDisplayShowHomeEnabled(true); } // add back arrow to toolbar if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
[ " getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n" ]
[ { "title": "in_file#lines#0.5", "text": " getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo", "score": 1 }, { "title": "in_file#lines#0.75", "text": " getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "getSupportActionBar setDisplayShowHomeEnabled attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_E", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_46_12
} if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
[ "getSupportActionBar().setDisplayShowHomeEnabled(true);\n" ]
[ { "title": "in_file#lines#0.5", "text": " }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri H", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_47_0
// AttrJob getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true);
}
[ " }\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.set", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "attrJob setCopies spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri H", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_51_4
Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter); // AttrJob
attrJob.setCopies(1);
[ " attrJob.setCopies(1);\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItem", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "spinnerSelectPrinter findViewById R id spinnerSelectPrinter adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_53_39
ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList()); adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice); attrJob.setCopies(1); Spinner spinnerSelectPrinter =
findViewById(R.id.spinnerSelectPrinter);
[ "findViewById(R.id.spinnerSelectPrinter);\n" ]
[ { "title": "in_file#lines#0.5", "text": " ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.", "score": 1 }, { "title": "in_file#lines#0.75", "text": " ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "adapterSelectPrinter android R layout simple_spinner_item getPrinterList adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_54_86
adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice); spinnerSelectPrinter.setAdapter(adapterSelectPrinter); Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter); ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.
layout.simple_spinner_item,getPrinterList());
[ "layout.simple_spinner_item,getPrinterList());\n" ]
[ { "title": "in_file#lines#0.5", "text": " adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show", "score": 1 }, { "title": "in_file#lines#0.75", "text": " adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .set", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "adapterSelectPrinter setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_55_70
spinnerSelectPrinter.setAdapter(adapterSelectPrinter); spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter); ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList()); adapterSelectPrinter.setDropDownViewResource(android.R.layout.
simple_list_item_single_choice);
[ "simple_list_item_single_choice);\n" ]
[ { "title": "in_file#lines#0.5", "text": " spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "spinnerSelectPrinter setAdapter adapterSelectPrinter spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_56_8
spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList()); adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
spinnerSelectPrinter.setAdapter(adapterSelectPrinter);
[ "spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n" ]
[ { "title": "in_file#lines#0.5", "text": " spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job", "score": 1 }, { "title": "in_file#lines#0.75", "text": " spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "spinnerSelectPrinter setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setH", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_57_29
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice); spinnerSelectPrinter.setAdapter(adapterSelectPrinter); spinnerSelectPrinter.
setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
[ "setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n" ]
[ { "title": "in_file#lines#0.5", "text": " @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n", "score": 1 }, { "title": "in_file#lines#0.75", "text": " @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "Override onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle set", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_58_3
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if(position==1){ spinnerSelectPrinter.setAdapter(adapterSelectPrinter); spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
[ " @Override\n" ]
[ { "title": "in_file#lines#0.5", "text": " public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attr", "score": 1 }, { "title": "in_file#lines#0.75", "text": " public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "onItemSelected parent view position id position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAl", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_59_12
if(position==1){ attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL); spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
[ "public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n" ]
[ { "title": "in_file#lines#0.5", "text": " if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();", "score": 1 }, { "title": "in_file#lines#0.75", "text": " if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "position attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER set", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_60_13
attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL); }else{ @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if(position==1){
[ " if(position==1){\n" ]
[ { "title": "in_file#lines#0.5", "text": " attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);", "score": 1 }, { "title": "in_file#lines#0.75", "text": " attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "attrJob setPrinter RawbtPrintJob PRINTER_VIRTUAL attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_61_8
}else{ attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT); public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if(position==1){
attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);
[ " attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n" ]
[ { "title": "in_file#lines#0.5", "text": " }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false", "score": 1 }, { "title": "in_file#lines#0.75", "text": " }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType B", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_62_5
attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT); } if(position==1){ attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);
}else{
[ " }else{\n" ]
[ { "title": "in_file#lines#0.5", "text": " attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);", "score": 1 }, { "title": "in_file#lines#0.75", "text": " attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findView", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "attrJob setPrinter RawbtPrintJob PRINTER_CURRENT Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType B", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_63_39
} } attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL); }else{ attrJob.setPrinter(
RawbtPrintJob.PRINTER_CURRENT);
[ "RawbtPrintJob.PRINTER_CURRENT);\n" ]
[ { "title": "in_file#lines#0.5", "text": " }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n find", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attr", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_64_0
} }else{ attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);
}
[ " }\n" ]
[ { "title": "in_file#lines#0.5", "text": " }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attr", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_65_0
@Override attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT); }
}
[ " }\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attr", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_b", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "Override onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attr", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_67_5
public void onNothingSelected(AdapterView<?> parent) { }
@Override
[ " @Override\n" ]
[ { "title": "in_file#lines#0.5", "text": " public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title", "score": 1 }, { "title": "in_file#lines#0.75", "text": " public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrue", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "onNothingSelected parent spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStr", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_68_24
} @Override public void
onNothingSelected(AdapterView<?> parent) {
[ "onNothingSelected(AdapterView<?> parent) {\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò,", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_70_0
}); public void onNothingSelected(AdapterView<?> parent) {
}
[ " }\n" ]
[ { "title": "in_file#lines#0.5", "text": " });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n", "score": 1 }, { "title": "in_file#lines#0.75", "text": " });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_71_2
}
});
[ " });\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é,", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptions", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "spinnerSelectTemplate findViewById R id spinnerSelectTemplate adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_74_40
ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList()); adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice); Spinner spinnerSelectTemplate =
findViewById(R.id.spinnerSelectTemplate);
[ "findViewById(R.id.spinnerSelectTemplate);\n" ]
[ { "title": "in_file#lines#0.5", "text": " ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then", "score": 1 }, { "title": "in_file#lines#0.75", "text": " ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý,", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "adapterSelectTemplate android R layout simple_spinner_item getTemplateList adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_75_57
adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice); spinnerSelectTemplate.setAdapter(adapterSelectTemplate); Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate); ArrayAdapter<String> adapterSelectTemplate = new
ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());
[ "ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n" ]
[ { "title": "in_file#lines#0.5", "text": " adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");", "score": 1 }, { "title": "in_file#lines#0.75", "text": " adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "adapterSelectTemplate setDropDownViewResource android R layout simple_list_item_single_choice spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType B", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_76_64
spinnerSelectTemplate.setAdapter(adapterSelectTemplate); spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate); ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList()); adapterSelectTemplate.setDropDownViewResource(android.R.
layout.simple_list_item_single_choice);
[ "layout.simple_list_item_single_choice);\n" ]
[ { "title": "in_file#lines#0.5", "text": " spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä,", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "spinnerSelectTemplate setAdapter adapterSelectTemplate spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a set", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_77_8
spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList()); adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
spinnerSelectTemplate.setAdapter(adapterSelectTemplate);
[ "spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n" ]
[ { "title": "in_file#lines#0.5", "text": " spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "spinnerSelectTemplate setOnItemSelectedListener Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView OnItemSelectedListener AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_78_4
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice); spinnerSelectTemplate.setAdapter(adapterSelectTemplate);
spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
[ " spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n" ]
[ { "title": "in_file#lines#0.5", "text": " @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "Override onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job bar", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_79_6
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if(position == 1){ spinnerSelectTemplate.setAdapter(adapterSelectTemplate); spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
[ " @Override\n" ]
[ { "title": "in_file#lines#0.5", "text": " public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())", "score": 1 }, { "title": "in_file#lines#0.75", "text": " public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "onItemSelected parent view position id position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView View AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_80_73
if(position == 1){ attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE); spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
[ "int position, long id) {\n" ]
[ { "title": "in_file#lines#0.5", "text": " if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAl", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "position attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_C", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_81_5
attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE); }else{ @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if(position == 1){
[ " if(position == 1){\n" ]
[ { "title": "in_file#lines#0.5", "text": " attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "attrJob setTemplate RawbtPrintJob TEMPLATE_NONE attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_82_11
}else{ attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT); public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if(position == 1){
attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);
[ " attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n" ]
[ { "title": "in_file#lines#0.5", "text": " }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)", "score": 1 }, { "title": "in_file#lines#0.75", "text": " }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_83_4
attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT); } if(position == 1){ attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);
}else{
[ " }else{\n" ]
[ { "title": "in_file#lines#0.5", "text": " attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDouble", "score": 1 }, { "title": "in_file#lines#0.75", "text": " attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "attrJob setTemplate RawbtPrintJob TEMPLATE_DEFAULT Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_84_20
} } attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE); }else{
attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);
[ "attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n" ]
[ { "title": "in_file#lines#0.5", "text": " }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_85_0
} }else{ attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);
}
[ " }\n" ]
[ { "title": "in_file#lines#0.5", "text": " }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Dec", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList =", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_86_0
@Override attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT); }
}
[ " }\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "Override onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_88_5
public void onNothingSelected(AdapterView<?> parent) { }
@Override
[ " @Override\n" ]
[ { "title": "in_file#lines#0.5", "text": " public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "onNothingSelected parent spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_89_24
} @Override public void
onNothingSelected(AdapterView<?> parent) {
[ "onNothingSelected(AdapterView<?> parent) {\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString f", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_91_0
}); public void onNothingSelected(AdapterView<?> parent) {
}
[ " }\n" ]
[ { "title": "in_file#lines#0.5", "text": " });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold =", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_92_0
Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies); }
});
[ " });\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "spinnerNumbersCopies findViewById R id spinnerNumbersCopies adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "Spinner ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_94_52
ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies()); adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice); }); Spinner spinnerNumbersCopies = findViewById(
R.id.spinnerNumbersCopies);
[ "R.id.spinnerNumbersCopies);\n" ]
[ { "title": "in_file#lines#0.5", "text": " ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h", "score": 1 }, { "title": "in_file#lines#0.75", "text": " ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n array", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "adapterNumbersCopies android R layout simple_spinner_item getNumbersCopies adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "ArrayAdapter String ArrayAdapter AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_95_93
adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice); spinnerNumbersCopies.setAdapter(adapterNumbersCopies); Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies); ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.
simple_spinner_item,getNumbersCopies());
[ "simple_spinner_item,getNumbersCopies());\n" ]
[ { "title": "in_file#lines#0.5", "text": " adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "adapterNumbersCopies setDropDownViewResource android R layout simple_list_item_single_choice spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_96_29
spinnerNumbersCopies.setAdapter(adapterNumbersCopies); spinnerNumbersCopies.setSelection(attrJob.getCopies()-1); Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies); ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies()); adapterNumbersCopies.
setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
[ "setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n" ]
[ { "title": "in_file#lines#0.5", "text": " spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString", "score": 1 }, { "title": "in_file#lines#0.75", "text": " spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "spinnerNumbersCopies setAdapter adapterNumbersCopies spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_97_8
spinnerNumbersCopies.setSelection(attrJob.getCopies()-1); spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies()); adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
spinnerNumbersCopies.setAdapter(adapterNumbersCopies);
[ "spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n" ]
[ { "title": "in_file#lines#0.5", "text": " spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(", "score": 1 }, { "title": "in_file#lines#0.75", "text": " spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new Raw", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "spinnerNumbersCopies setSelection attrJob getCopies spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_98_8
spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice); spinnerNumbersCopies.setAdapter(adapterNumbersCopies);
spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);
[ "spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n" ]
[ { "title": "in_file#lines#0.5", "text": " spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);", "score": 1 }, { "title": "in_file#lines#0.75", "text": " spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "spinnerNumbersCopies setOnItemSelectedListener Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show print", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView OnItemSelectedListener AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_99_29
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { spinnerNumbersCopies.setAdapter(adapterNumbersCopies); spinnerNumbersCopies.setSelection(attrJob.getCopies()-1); spinnerNumbersCopies.
setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
[ "setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n" ]
[ { "title": "in_file#lines#0.5", "text": " @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "Override onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrint", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_100_3
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { attrJob.setCopies(position+1); spinnerNumbersCopies.setSelection(attrJob.getCopies()-1); spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
[ " @Override\n" ]
[ { "title": "in_file#lines#0.5", "text": " public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT", "score": 1 }, { "title": "in_file#lines#0.75", "text": " public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "onItemSelected parent view position id attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView View AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onItemSelected onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_101_19
attrJob.setCopies(position+1); } spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public
void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
[ "void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n" ]
[ { "title": "in_file#lines#0.5", "text": " attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint),", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "attrJob setCopies position Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_102_0
} @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
attrJob.setCopies(position+1);
[ " attrJob.setCopies(position+1);\n" ]
[ { "title": "in_file#lines#0.5", "text": " }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font", "score": 1 }, { "title": "in_file#lines#0.75", "text": " }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrint", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_103_0
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { attrJob.setCopies(position+1);
}
[ " }\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "Override onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrint", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_105_5
public void onNothingSelected(AdapterView<?> parent) { }
@Override
[ " @Override\n" ]
[ { "title": "in_file#lines#0.5", "text": " public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h", "score": 1 }, { "title": "in_file#lines#0.75", "text": " public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.get", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new Rawbt", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "onNothingSelected parent findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintC", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "AdapterView MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onNothingSelected onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_106_42
} @Override public void onNothingSelected(
AdapterView<?> parent) {
[ "AdapterView<?> parent) {\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString att", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast make", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_108_0
}); public void onNothingSelected(AdapterView<?> parent) {
}
[ " }\n" ]
[ { "title": "in_file#lines#0.5", "text": " });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",", "score": 1 }, { "title": "in_file#lines#0.75", "text": " });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast make", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_109_2
// Examples }
});
[ " });\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinter", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "findViewById R id sdk_test1 setOnClickListener v demo_job findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast make", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_113_59
findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font()); findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image()); // Examples findViewById(R.id.sdk_test1).setOnClickListener((v)
->demo_job());
[ "->demo_job());\n" ]
[ { "title": "in_file#lines#0.5", "text": " findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double", "score": 1 }, { "title": "in_file#lines#0.75", "text": " findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "findViewById R id sdk_test_font setOnClickListener v demo_font findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintError Nullable jobId message", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_114_41
findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image()); findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job()); findViewById(R.id.sdk_test_font).
setOnClickListener((v)->demo_font());
[ "setOnClickListener((v)->demo_font());\n" ]
[ { "title": "in_file#lines#0.5", "text": " findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAl", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "findViewById R id sdk_test_image setOnClickListener v demo_image findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintError Nullable jobId message Toast makeText message Toast LENGTH_SHORT show Override handlePrintProgress jobId p", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_115_26
findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode()); findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job()); findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font()); findViewById(R.id.
sdk_test_image).setOnClickListener((v)->demo_image());
[ "sdk_test_image).setOnClickListener((v)->demo_image());\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n ", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "findViewById R id sdk_test_barcode setOnClickListener v demo_barcode findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintError Nullable jobId message Toast makeText message Toast LENGTH_SHORT show Override handlePrintProgress jobId p MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList Array", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_117_26
findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2()); findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image()); findViewById(R.id.
sdk_test_barcode).setOnClickListener((v)->demo_barcode());
[ "sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n" ]
[ { "title": "in_file#lines#0.5", "text": " findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont", "score": 1 }, { "title": "in_file#lines#0.75", "text": " findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n Attributes", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.set", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "findViewById R id sdk_test_barcode2 setOnClickListener v demo_barcode2 findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintError Nullable jobId message Toast makeText message Toast LENGTH_SHORT show Override handlePrintProgress jobId p MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_118_23
findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format()); findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode()); findViewById(R.
id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());
[ "id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setPrinterFont(FONT_A).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true).setDouble", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "findViewById R id sdk_test_rich_format setOnClickListener v demo_rich_format Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintError Nullable jobId message Toast makeText message Toast LENGTH_SHORT show Override handlePrintProgress jobId p MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString Attributes", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_120_48
} findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2()); findViewById(R.id.sdk_test_rich_format).
setOnClickListener((v)->demo_rich_format());
[ "setOnClickListener((v)->demo_rich_format());\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, �", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setPrinterFont(FONT_A).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true).setDoubleWidth(true);\n\n job.println(\"Rich Format\",attrStrTitle);\n job.drawLine('*',attr", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintError Nullable jobId message Toast makeText message Toast LENGTH_SHORT show Override handlePrintProgress jobId p MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString Attributes", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_122_0
@Override findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());
}
[ " }\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È,", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setPrinterFont(FONT_A).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true).setDoubleWidth(true);\n\n job.println(\"Rich Format\",attrStrTitle);\n job.drawLine('*',attrStrTitle);\n\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDouble", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "Override onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintError Nullable jobId message Toast makeText message Toast LENGTH_SHORT show Override handlePrintProgress jobId p MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString Attributes", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_124_3
public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); }
@Override
[ " @Override\n" ]
[ { "title": "in_file#lines#0.5", "text": " public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, �", "score": 1 }, { "title": "in_file#lines#0.75", "text": " public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setPrinterFont(FONT_A).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true).setDoubleWidth(true);\n\n job.println(\"Rich Format\",attrStrTitle);\n job.drawLine('*',attrStrTitle);\n\n job", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "onOptionsItemSelected item id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintError Nullable jobId message Toast makeText message Toast LENGTH_SHORT show Override handlePrintProgress jobId p MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "MenuItem ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "onOptionsItemSelected getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_125_11
int id = item.getItemId(); if (id == android.R.id.home) { @Override public
boolean onOptionsItemSelected(MenuItem item) {
[ "boolean onOptionsItemSelected(MenuItem item) {\n" ]
[ { "title": "in_file#lines#0.5", "text": " int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, �", "score": 1 }, { "title": "in_file#lines#0.75", "text": " int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setPrinterFont(FONT_A).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true).setDoubleWidth(true);\n\n job.println(\"Rich Format\",attrStrTitle);\n job.drawLine('*',attrStrTitle);\n\n job.println(\"drawLine(char) - print full line of char\");\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "id item getItemId id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintError Nullable jobId message Toast makeText message Toast LENGTH_SHORT show Override handlePrintProgress jobId p ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_126_22
if (id == android.R.id.home) { finish(); @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.
getItemId();
[ "getItemId();\n" ]
[ { "title": "in_file#lines#0.5", "text": " if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, �", "score": 1 }, { "title": "in_file#lines#0.75", "text": " if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setPrinterFont(FONT_A).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true).setDoubleWidth(true);\n\n job.println(\"Rich Format\",attrStrTitle);\n job.drawLine('*',attrStrTitle);\n\n job.println(\"drawLine(char) - print full line of char\");\n job.drawLine('-');\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "id android R id home finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintError Nullable jobId message Toast makeText message Toast LENGTH_SHORT show Override handlePrintProgress jobId p ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString Attributes", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_127_4
finish(); } public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId();
if (id == android.R.id.home) {
[ " if (id == android.R.id.home) {\n" ]
[ { "title": "in_file#lines#0.5", "text": " finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, ", "score": 1 }, { "title": "in_file#lines#0.75", "text": " finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setPrinterFont(FONT_A).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true).setDoubleWidth(true);\n\n job.println(\"Rich Format\",attrStrTitle);\n job.drawLine('*',attrStrTitle);\n\n job.println(\"drawLine(char) - print full line of char\");\n job.drawLine('-');\n job.drawLine('=');\n job.", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "finish onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintError Nullable jobId message Toast makeText message Toast LENGTH_SHORT show Override handlePrintProgress jobId p ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString Attributes", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_128_5
} return super.onOptionsItemSelected(item); int id = item.getItemId(); if (id == android.R.id.home) {
finish();
[ " finish();\n" ]
[ { "title": "in_file#lines#0.5", "text": " }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û,", "score": 1 }, { "title": "in_file#lines#0.75", "text": " }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setPrinterFont(FONT_A).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true).setDoubleWidth(true);\n\n job.println(\"Rich Format\",attrStrTitle);\n job.drawLine('*',attrStrTitle);\n\n job.println(\"drawLine(char) - print full line of char\");\n job.drawLine('-');\n job.drawLine('=');\n job.drawLine('.');\n job", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintError Nullable jobId message Toast makeText message Toast LENGTH_SHORT show Override handlePrintProgress jobId p ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString Raw", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_129_0
return super.onOptionsItemSelected(item); } if (id == android.R.id.home) { finish();
}
[ " }\n" ]
[ { "title": "in_file#lines#0.5", "text": " return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ,", "score": 1 }, { "title": "in_file#lines#0.75", "text": " return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setPrinterFont(FONT_A).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true).setDoubleWidth(true);\n\n job.println(\"Rich Format\",attrStrTitle);\n job.drawLine('*',attrStrTitle);\n\n job.println(\"drawLine(char) - print full line of char\");\n job.drawLine('-');\n job.drawLine('=');\n job.drawLine('.');\n job.ln(2);\n\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "onOptionsItemSelected item getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintError Nullable jobId message Toast makeText message Toast LENGTH_SHORT show Override handlePrintProgress jobId p ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString Raw", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_130_21
} finish(); } return super.
onOptionsItemSelected(item);
[ "onOptionsItemSelected(item);\n" ]
[ { "title": "in_file#lines#0.5", "text": " }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, �", "score": 1 }, { "title": "in_file#lines#0.75", "text": " }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setPrinterFont(FONT_A).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true).setDoubleWidth(true);\n\n job.println(\"Rich Format\",attrStrTitle);\n job.drawLine('*',attrStrTitle);\n\n job.println(\"drawLine(char) - print full line of char\");\n job.drawLine('-');\n job.drawLine('=');\n job.drawLine('.');\n job.ln(2);\n\n job.println(\"leftRightText() \");\n ", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n ", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintError Nullable jobId message Toast makeText message Toast LENGTH_SHORT show Override handlePrintProgress jobId p ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrint", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_131_0
// ------------------------------ } return super.onOptionsItemSelected(item);
}
[ " }\n" ]
[ { "title": "in_file#lines#0.5", "text": "\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö", "score": 1 }, { "title": "in_file#lines#0.75", "text": "\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setPrinterFont(FONT_A).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true).setDoubleWidth(true);\n\n job.println(\"Rich Format\",attrStrTitle);\n job.drawLine('*',attrStrTitle);\n\n job.println(\"drawLine(char) - print full line of char\");\n job.drawLine('-');\n job.drawLine('=');\n job.drawLine('.');\n job.ln(2);\n\n job.println(\"leftRightText() \");\n job", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": "\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "getPrinterList arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintError Nullable jobId message Toast makeText message Toast LENGTH_SHORT show Override handlePrintProgress jobId p ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrint", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "getPrinterList getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_135_30
ArrayList<String> arrayList = new ArrayList<>(); arrayList.add(RawbtPrintJob.PRINTER_CURRENT); // ------------------------------ private ArrayList<String>
getPrinterList() {
[ "getPrinterList() {\n" ]
[ { "title": "in_file#lines#0.5", "text": " ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, �", "score": 1 }, { "title": "in_file#lines#0.75", "text": " ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setPrinterFont(FONT_A).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true).setDoubleWidth(true);\n\n job.println(\"Rich Format\",attrStrTitle);\n job.drawLine('*',attrStrTitle);\n\n job.println(\"drawLine(char) - print full line of char\");\n job.drawLine('-');\n job.drawLine('=');\n job.drawLine('.');\n job.ln(2);\n\n job.println(\"leftRightText() \");\n job.drawLine('-');\n job.leftRightText(\"left part\",\"right", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " ArrayList<String> arrayList = new ArrayList<>();\n arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "arrayList arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintError Nullable jobId message Toast makeText message Toast LENGTH_SHORT show Override handlePrintProgress jobId p ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "ArrayList String ArrayList ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]
data/train/402d/RawbtAPI/sample/src/main/java/ru/a402d/rawbtapidemo/DemoSdkActivity.java_136_26
arrayList.add(RawbtPrintJob.PRINTER_CURRENT); arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL); private ArrayList<String> getPrinterList() { ArrayList<String>
arrayList = new ArrayList<>();
[ "arrayList = new ArrayList<>();\n" ]
[ { "title": "in_file#lines#0.5", "text": " arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç", "score": 1 }, { "title": "in_file#lines#0.75", "text": " arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .setPrinterFont(FONT_A);\n AttributesString fAw1h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true);\n AttributesString fAw2h1 = new AttributesString()\n .setPrinterFont(FONT_A)\n .setDoubleWidth(true);\n AttributesString fAw2h2 = (new AttributesString())\n .setPrinterFont(FONT_A)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n AttributesString fBw1h1 = (new AttributesString())\n .setPrinterFont(FONT_B);\n AttributesString fBw1h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true);\n AttributesString fBw2h1 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleWidth(true);\n AttributesString fBw2h2 = (new AttributesString())\n .setPrinterFont(FONT_B)\n .setDoubleHeight(true)\n .setDoubleWidth(true);\n\n job.println(\"Normal Font A\",fAw1h1);\n job.println(\"Double height\",fAw1h2);\n job.println(\"Double width\",fAw2h1);\n job.println(\"width & height\",fAw2h2);\n job.ln();\n\n job.println(\"Normal Font B\",fBw1h1);\n job.println(\"Double height\",fBw1h2);\n job.println(\"Double width\",fBw2h1);\n job.println(\"width & height\",fBw2h2);\n job.ln(3);\n\n job.println(\"True Type\",attrStrTitle);\n\n AttributesString attrTrueType = (new AttributesString()).setPrinterFont(FONT_TRUE_TYPE);\n job.println(\"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\",attrTrueType);\n job.println(\"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType);\n job.ln(2);\n\n job.println(\"Alignment\",attrStrTitle);\n AttributesString left = new AttributesString().setAlignment(ALIGNMENT_LEFT);\n AttributesString right = new AttributesString().setAlignment(ALIGNMENT_RIGHT);\n AttributesString center = new AttributesString().setAlignment(ALIGNMENT_CENTER);\n\n job.println(\"left\",left);\n job.println(\"center\",center);\n job.println(\"right\",right);\n job.ln(2);\n\n job.println(\"Decoration\",attrStrTitle);\n AttributesString bold = new AttributesString().setBold(true);\n AttributesString underline = new AttributesString().setUnderline(true);\n AttributesString underlineBold = new AttributesString().setUnderline(true).setBold(true);\n job.println(\"Normal text\");\n job.println(\"Bold text.\",bold);\n job.println(\"Underline text\",underline);\n job.println(\"Underline bold\",underlineBold);\n job.ln(2);\n\n job.println(\"Notice\",bold);\n job.println(\"Using different styles on the same line is not supported. See rich format.\");\n job.ln();\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_rich_format(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setPrinterFont(FONT_A).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true).setDoubleWidth(true);\n\n job.println(\"Rich Format\",attrStrTitle);\n job.drawLine('*',attrStrTitle);\n\n job.println(\"drawLine(char) - print full line of char\");\n job.drawLine('-');\n job.drawLine('=');\n job.drawLine('.');\n job.ln(2);\n\n job.println(\"leftRightText() \");\n job.drawLine('-');\n job.leftRightText(\"left part\",\"right part\");\n job.leftIndentRightText(6,\"left indent", "score": 0.5 }, { "title": "in_file#lines#0.25", "text": " arrayList.add(RawbtPrintJob.PRINTER_CURRENT);\n arrayList.add(RawbtPrintJob.PRINTER_VIRTUAL);\n return arrayList;\n }\n\n private ArrayList<String> getTemplateList() {\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(RawbtPrintJob.TEMPLATE_DEFAULT);\n arrayList.add(RawbtPrintJob.TEMPLATE_NONE);\n\n return arrayList;\n }\n\n private static ArrayList<String> getNumbersCopies(){\n ArrayList<String> arrayList = new ArrayList<>();\n\n arrayList.add(\"1\");\n arrayList.add(\"2\");\n arrayList.add(\"3\");\n arrayList.add(\"4\");\n arrayList.add(\"5\");\n arrayList.add(\"6\");\n arrayList.add(\"7\");\n arrayList.add(\"8\");\n arrayList.add(\"9\");\n arrayList.add(\"10\");\n\n return arrayList;\n }\n\n // ------------------------------\n\n private void demo_job(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n job.println(\"Hello,World!\");\n\n Toast.makeText(this, getString(R.string.btnTxtPrint), Toast.LENGTH_SHORT).show();\n printJob(job);\n }\n\n private void demo_font(){\n RawbtPrintJob job = new RawbtPrintJob();\n\n job.setPrinter(attrJob.getPrinter());\n job.setTemplate(attrJob.getTemplate());\n job.setCopies(attrJob.getCopies());\n\n // default values\n AttributesString attrStr = new AttributesString();\n attrStr.setPrinterFont(FONT_A);\n attrStr.setAlignment(ALIGNMENT_LEFT);\n attrStr.setBold(false);\n attrStr.setUnderline(false);\n attrStr.setDoubleHeight(false);\n attrStr.setDoubleWidth(false);\n\n // set it as default for job\n job.setDefaultAttrString(attrStr);\n\n // attr for title\n AttributesString attrStrTitle = (new AttributesString()).setAlignment(ALIGNMENT_CENTER).setDoubleHeight(true);\n\n job.println(\"Important\",attrStrTitle);\n\n\n job.println(\"If a document requires several styles, then specify them explicitly for each purpose.\");\n job.println(\"Since the arguments are passed by reference, do not change the values of the arguments along the way.\");\n job.ln();\n\n job.println(\"Font sizes\",attrStrTitle);\n\n AttributesString fAw1h1 = (new AttributesString())\n .set", "score": 0.3333333333333333 }, { "title": "in_file#identifiers#0.5", "text": "arrayList add RawbtPrintJob PRINTER_CURRENT arrayList add RawbtPrintJob PRINTER_VIRTUAL arrayList getTemplateList arrayList arrayList add RawbtPrintJob TEMPLATE_DEFAULT arrayList add RawbtPrintJob TEMPLATE_NONE arrayList getNumbersCopies arrayList arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList add arrayList demo_job job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies job println Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_font job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job println job ln job println attrStrTitle fAw1h1 setPrinterFont FONT_A fAw1h2 setPrinterFont FONT_A setDoubleHeight fAw2h1 setPrinterFont FONT_A setDoubleWidth fAw2h2 setPrinterFont FONT_A setDoubleHeight setDoubleWidth fBw1h1 setPrinterFont FONT_B fBw1h2 setPrinterFont FONT_B setDoubleHeight fBw2h1 setPrinterFont FONT_B setDoubleWidth fBw2h2 setPrinterFont FONT_B setDoubleHeight setDoubleWidth job println fAw1h1 job println fAw1h2 job println fAw2h1 job println fAw2h2 job ln job println fBw1h1 job println fBw1h2 job println fBw2h1 job println fBw2h2 job ln job println attrStrTitle attrTrueType setPrinterFont FONT_TRUE_TYPE job println attrTrueType job println job ln job println attrStrTitle left setAlignment ALIGNMENT_LEFT right setAlignment ALIGNMENT_RIGHT center setAlignment ALIGNMENT_CENTER job println left job println center job println right job ln job println attrStrTitle bold setBold underline setUnderline underlineBold setUnderline setBold job println job println bold job println underline job println underlineBold job ln job println bold job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_rich_format job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStr attrStr setPrinterFont FONT_A attrStr setAlignment ALIGNMENT_LEFT attrStr setBold attrStr setUnderline attrStr setDoubleHeight attrStr setDoubleWidth job setDefaultAttrString attrStr attrStrTitle setPrinterFont FONT_A setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job drawLine attrStrTitle job println job drawLine job drawLine job drawLine job ln job println job drawLine job leftRightText job leftIndentRightText job leftRightIndentText job drawLine job leftRightTextWithFormat attrStrTitle job leftRightText job leftRightTextWithBothFormat attrStr build setDoubleWidth attrStr build setDoubleHeight Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_image job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies uri Uri parse getPackageName R raw bwlogo attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job image uri job ln job println job ln im50center setScale setAlignment ALIGNMENT_CENTER job image uri im50center job ln job println job ln im75right setScale setAlignment ALIGNMENT_RIGHT job image uri im75right job ln job println job ln im25left setScale setAlignment ALIGNMENT_LEFT job image uri im25left job ln job println job ln imRotated setRotateImage job image uri imRotated job ln job println job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight job println attrStrTitle job println job ln job println job add BARCODE_UPC_A setHeight setAlignment ALIGNMENT_CENTER job ln job println job add BARCODE_UPC_A setHeight setHri HRI_ABOVE setAlignment ALIGNMENT_LEFT job ln job println job add BARCODE_UPC_A setHeight setHri HRI_BELOW setAlignment ALIGNMENT_RIGHT job ln job println setBold job ln job println job add BARCODE_UPC_E setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println job add BARCODE_UPC_E setHeight setHri HRI_BOTH job ln job println setBold job ln job println job add BARCODE_EAN13 setHeight setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job println job add BARCODE_EAN13 setHeight setWidth setHri HRI_BOTH job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job demo_barcode2 job job setPrinter attrJob getPrinter job setTemplate attrJob getTemplate job setCopies attrJob getCopies a setHeight setHri HRI_BELOW attrStrTitle setAlignment ALIGNMENT_CENTER setDoubleHeight setDoubleWidth job println attrStrTitle job barcode a setType BARCODE_UPC_A build job ln job println attrStrTitle job barcode a setType BARCODE_UPC_E build job ln job println attrStrTitle job barcode a setType BARCODE_EAN13 build job ln job println attrStrTitle job barcode a setType BARCODE_EAN8 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE39 build job ln job println attrStrTitle job barcode a setType BARCODE_ITF build job ln job println attrStrTitle job barcode a setType BARCODE_CODABAR build job ln job println attrStrTitle job barcode a setType BARCODE_CODE93 build job ln job println attrStrTitle job barcode a setType BARCODE_CODE128 build job ln Toast makeText getString R string btnTxtPrint Toast LENGTH_SHORT show printJob job Override handleServiceConnected Override handlePrintSuccess jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintCancel jobId Toast makeText Toast LENGTH_SHORT show Override handlePrintError Nullable jobId message Toast makeText message Toast LENGTH_SHORT show Override handlePrintProgress jobId p ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob Raw", "score": 0.25 }, { "title": "sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.2 }, { "title": "sibling_file#identifiers#0.5", "text": "", "score": 0.16666666666666666 }, { "title": "in_file#type_identifiers#0.5", "text": "ArrayList String ArrayList String ArrayList ArrayList String ArrayList String ArrayList RawbtPrintJob RawbtPrintJob RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob AttributesString AttributesString AttributesString AttributesString RawbtPrintJob RawbtPrintJob Uri AttributesString AttributesString AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage AttributesImage RawbtPrintJob RawbtPrintJob AttributesString AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode AttributesString CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode CommandBarcode RawbtPrintJob RawbtPrintJob AttributesBarcode AttributesBarcode AttributesString AttributesString String String String String String Float", "score": 0.14285714285714285 }, { "title": "in_file#method_names#0.5", "text": "getTemplateList getNumbersCopies demo_job demo_font demo_rich_format demo_image demo_barcode demo_barcode2 handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress", "score": 0.125 }, { "title": "sibling_file#field_declarations#0.5", "text": "", "score": 0.1111111111111111 }, { "title": "in_file#string_literals#0.5", "text": "\"1\" \"2\" \"3\" \"4\" \"5\" \"6\" \"7\" \"8\" \"9\" \"10\" \"Hello,World!\" \"Important\" \"If a document requires several styles, then specify them explicitly for each purpose.\" \"Since the arguments are passed by reference, do not change the values of the arguments along the way.\" \"Font sizes\" \"Normal Font A\" \"Double height\" \"Double width\" \"width & height\" \"Normal Font B\" \"Double height\" \"Double width\" \"width & height\" \"True Type\" \"If the printer does not support the required language, then text printing is available by creating a picture with text displayed in a truetype font.\" \"à, è, ì, ò, ù, À, È, Ì, Ò, Ù, á, é, í, ó, ú, ý, Á, É, Í, Ó, Ú, Ý, â, ê, î, ô, û, ð, Â, Ê, Î, Ô, Û, Ð, ã, ñ, õ, Ã, Ñ, Õ, ä, ë, ï, ö, ü, ÿ, Ä, Ë, Ï, Ö, Ü, Ÿ, å, Å, æ, œ, Æ, Œ or ß, ç, Ç, ¿, ¡\",attrTrueType); \"Alignment\" \"left\" \"center\" \"right\" \"Decoration\" \"Normal text\" \"Bold text.\" \"Underline text\" \"Underline bold\" \"Notice\" \"Using different styles on the same line is not supported. See rich format.\" \"Rich Format\" \"drawLine(char) - print full line of char\" \"leftRightText() \" \"left part\" \"right part\" \"left indent 6\" \"right part\" \"left part\" \"right indent 4\" \"Total\" \"100.00\" \"Long text as left part\" \"compare 58/80 mm\" \"width\" \"Height\" \"android.resource://\" \"/\" \"Images\" \"The picture is scaled to the width of the printer as a fraction. 16/16 means full width.Values 1-16 allowed.\" \"Scale 16(default) - full width\" \"Scale: 8(50%). Alignment: center\" \"Scale: 12(75%). Alignment: right\" \"Scale: 4(25%). Alignment: left\" \"Rotate\" \"Barcode\" \"HRI & Alignment\" \"Center / HRI none\" \"012345678905\" \"Left / HRI above\" \"012345678905\" \"Right / HRI bellow\" \"012345678905\" \"Height\" \"Default look\" \"0123456\" \"Minimum. 12 dots\" \"0123456\" \"Safe max. 192 dots\" \"01234565\" \"Width\" \"Default look\" \"012345678901\" \"1-4 for 58mm\" \"012345678901\" \"012345678901\" \"012345678901\" \"012345678901\" \"5-6 for 80mm or for 300 dpi\" \"5)\" \"012345678901\" \"6)\" \"012345678901\" \"Reduces the width when overflow\" \"7)\" \"012345678901\" \"8)\" \"012345678901\" \"UPC-A\" \"40204020402\" \"UPC-E\" \"0402402\" \"EAN13\" \"4606224236582\" \"EAN8\" \"4020402\" \"CODE39\" \"RAWBT-402D\" \"ITF\" \"30712345000010\" \"CODOBAR\" \"A4020402A\" \"CODE93\" \"RAWBT-402-/+\" \"CODE128\" \"RawBT402d\" \"Success\" \"Canceled\"", "score": 0.1 }, { "title": "sibling_file#type_identifiers#0.5", "text": "", "score": 0.09090909090909091 }, { "title": "sibling_file#string_literals#0.5", "text": "", "score": 0.08333333333333333 }, { "title": "similar_name_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.07692307692307693 }, { "title": "similar_name_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n \n[DemoSdkActivity]", "score": 0.07142857142857142 }, { "title": "in_file#field_declarations#0.5", "text": "private final RawbtPrintJob attrJob = new RawbtPrintJob();", "score": 0.06666666666666667 }, { "title": "sibling_file#method_names#0.5", "text": "", "score": 0.0625 }, { "title": "codex", "text": "package ru.a402d.rawbtapidemo;\n\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.view.MenuItem;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.ArrayAdapter;\nimport android.widget.Spinner;\nimport android.widget.Toast;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.widget.Toolbar;\n\nimport com.google.android.material.appbar.CollapsingToolbarLayout;\n\nimport java.util.ArrayList;\n\nimport rawbt.api.AppCompatWithRawbtActivity;\nimport rawbt.api.attributes.AttributesBarcode;\nimport rawbt.api.attributes.AttributesString;\nimport rawbt.api.attributes.AttributesImage;\nimport rawbt.api.command.CommandBarcode;\nimport rawbt.api.RawbtPrintJob;\nimport static rawbt.api.Constant.*;\n\n\npublic class DemoSdkActivity extends AppCompatWithRawbtActivity {\n\n private final RawbtPrintJob attrJob = new RawbtPrintJob();\n\n // -----------------------------------------\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n setContentView(R.layout.activity_demo_sdk);\n Toolbar toolbar = findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n CollapsingToolbarLayout toolBarLayout = findViewById(R.id.toolbar_layout);\n toolBarLayout.setTitle(getTitle());\n\n // add back arrow to toolbar\n if (getSupportActionBar()!= null) {\n getSupportActionBar().setDisplayHomeAsUpEnabled(true);\n getSupportActionBar().setDisplayShowHomeEnabled(true);\n }\n\n // AttrJob\n\n attrJob.setCopies(1);\n\n Spinner spinnerSelectPrinter = findViewById(R.id.spinnerSelectPrinter);\n ArrayAdapter<String> adapterSelectPrinter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getPrinterList());\n adapterSelectPrinter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectPrinter.setAdapter(adapterSelectPrinter);\n spinnerSelectPrinter.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position==1){\n attrJob.setPrinter(RawbtPrintJob.PRINTER_VIRTUAL);\n }else{\n attrJob.setPrinter(RawbtPrintJob.PRINTER_CURRENT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n\n Spinner spinnerSelectTemplate = findViewById(R.id.spinnerSelectTemplate);\n ArrayAdapter<String> adapterSelectTemplate = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item, getTemplateList());\n adapterSelectTemplate.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerSelectTemplate.setAdapter(adapterSelectTemplate);\n spinnerSelectTemplate.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n if(position == 1){\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_NONE);\n }else{\n attrJob.setTemplate(RawbtPrintJob.TEMPLATE_DEFAULT);\n }\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n Spinner spinnerNumbersCopies = findViewById(R.id.spinnerNumbersCopies);\n ArrayAdapter<String> adapterNumbersCopies = new ArrayAdapter<>(this,android.R.layout.simple_spinner_item,getNumbersCopies());\n adapterNumbersCopies.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);\n spinnerNumbersCopies.setAdapter(adapterNumbersCopies);\n spinnerNumbersCopies.setSelection(attrJob.getCopies()-1);\n spinnerNumbersCopies.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {\n @Override\n public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {\n attrJob.setCopies(position+1);\n }\n\n @Override\n public void onNothingSelected(AdapterView<?> parent) {\n\n }\n });\n\n // Examples\n\n findViewById(R.id.sdk_test1).setOnClickListener((v)->demo_job());\n findViewById(R.id.sdk_test_font).setOnClickListener((v)->demo_font());\n findViewById(R.id.sdk_test_image).setOnClickListener((v)->demo_image());\n\n findViewById(R.id.sdk_test_barcode).setOnClickListener((v)->demo_barcode());\n findViewById(R.id.sdk_test_barcode2).setOnClickListener((v)->demo_barcode2());\n\n findViewById(R.id.sdk_test_rich_format).setOnClickListener((v)->demo_rich_format());\n\n }\n\n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == android.R.id.home) {\n finish();\n }\n return super.onOptionsItemSelected(item);\n }\n\n // ------------------------------\n\n private ArrayList<String> getPrinterList() {\n ArrayList<String> ", "score": 0.058823529411764705 }, { "title": "similar_name_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false)); \n[DemoSdkActivity]", "score": 0.05555555555555555 }, { "title": "similar_name_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress \n[DemoSdkActivity]", "score": 0.05263157894736842 }, { "title": "similar_name_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float \n[DemoSdkActivity]", "score": 0.05 }, { "title": "similar_name_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.047619047619047616 }, { "title": "parent_class_file#method_names_and_bodies#0.5", "text": "[AppCompatWithRawbtActivity] [onServiceConnected] try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n } [onServiceDisconnected] public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n } [onPrintSuccess] public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n } [onPrintError] final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n } [onPrintCancel] public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n } [onProgress] final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n } [bindRawBT] \n }\n }catch (Exception e) {\n handlePrintError(null,getString(R.string.rawbt_connect_error));\n }\n } [onCreate] Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n\n if(serviceRawBT==null) {\n bindRawBT(true);\n }\n } [onDestroy] protected void onDestroy() {\n super.onDestroy();\n if(serviceRawBT!= null){\n unbindService(connectService);\n }\n } [printJob] R.string.rawbt_permission_not_granted));\n }catch (Exception e){\n handlePrintError(job.idJob,e.getLocalizedMessage());\n }\n } [handleServiceConnected] abstract protected void handleServiceConnected();\n [handlePrintSuccess] abstract protected void handlePrintSuccess(String jobId);\n [handlePrintCancel] protected void handlePrintCancel(String jobId);\n [handlePrintError] (@Nullable String jobId, String message);\n [handlePrintProgress] handlePrintProgress(String jobId,Float p);\n\n[DemoSdkActivity]", "score": 0.045454545454545456 }, { "title": "child_class_file#identifiers#0.5", "text": "", "score": 0.043478260869565216 }, { "title": "child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.041666666666666664 }, { "title": "parent_class_file#identifiers#0.5", "text": "[AppCompatWithRawbtActivity] rawbt api android content ComponentName android content Context android content ServiceConnection android content pm PackageManager android os Build android os Bundle android os Handler android os IBinder android os Looper androidx activity result ActivityResultLauncher androidx activity result contract ActivityResultContracts androidx annotation NonNull androidx annotation Nullable androidx appcompat app AppCompatActivity rawbt sdk ICallback rawbt sdk IRawBtPrintService AppCompatWithRawbtActivity handler Looper getMainLooper serviceRawBT connectService Override onServiceConnected name s serviceRawBT IRawBtPrintService Stub asInterface s serviceRawBT registerCallback serviceCallback handler post handleServiceConnected e handlePrintError e getLocalizedMessage Override onServiceDisconnected name serviceRawBT handler postDelayed bindRawBT serviceCallback Override onPrintSuccess jobId finalJobId jobId handler post handlePrintSuccess finalJobId Override onPrintError jobId errMessage finalJobId jobId finalMes errMessage handler post handlePrintError finalJobId finalMes Override onPrintCancel jobId finalJobId jobId handler post handlePrintCancel finalJobId Override onProgress jobId p finalJobId jobId finalP p handler post handlePrintProgress finalJobId finalP bindRawBT allowRequestPerm bindService RawbtApiHelper createExplicitIntent connectService Context BIND_AUTO_CREATE s allowRequestPerm Build VERSION SDK_INT Build VERSION_CODES M checkSelfPermission RawbtApiHelper SERVICE_PERMISSION PackageManager PERMISSION_GRANTED mRequestPermission launch RawbtApiHelper SERVICE_PERMISSION handlePrintError getString R string rawbt_permission_not_granted e handlePrintError getString R string rawbt_connect_error mRequestPermission registerForActivityResult isGranted bindRawBT Override onCreate savedInstanceState onCreate savedInstanceState serviceRawBT bindRawBT Override onDestroy onDestroy serviceRawBT unbindService connectService printJob NonNull job serviceRawBT RawbtApiHelper isServiceInstalled handlePrintError job idJob getString R string rawb_not_installed bindRawBT handlePrintError job idJob getString R string rawbt_please_wait serviceRawBT printRawbtPrintJob job GSON s handlePrintError job idJob getString R string rawbt_permission_not_granted e handlePrintError job idJob e getLocalizedMessage handleServiceConnected handlePrintSuccess jobId handlePrintCancel jobId handlePrintError Nullable jobId message handlePrintProgress jobId p AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.04 }, { "title": "child_class_file#method_names#0.5", "text": "", "score": 0.038461538461538464 }, { "title": "parent_class_file#method_names#0.5", "text": "[AppCompatWithRawbtActivity] onServiceConnected onServiceDisconnected onPrintSuccess onPrintError onPrintCancel onProgress bindRawBT onCreate onDestroy printJob handleServiceConnected handlePrintSuccess handlePrintCancel handlePrintError handlePrintProgress\n[DemoSdkActivity]", "score": 0.037037037037037035 }, { "title": "child_class_file#type_identifiers#0.5", "text": "", "score": 0.03571428571428571 }, { "title": "parent_class_file#field_declarations#0.5", "text": "[AppCompatWithRawbtActivity] final protected Handler handler = new Handler(Looper.getMainLooper()); public volatile IRawBtPrintService serviceRawBT = null; private final ServiceConnection connectService = new ServiceConnection() {\n\n @Override\n public void onServiceConnected(ComponentName name, IBinder s) {\n serviceRawBT = IRawBtPrintService.Stub.asInterface(s);\n try {\n serviceRawBT.registerCallback(serviceCallback);\n handler.post(()-> handleServiceConnected());\n } catch (Exception e) {\n handlePrintError(null,e.getLocalizedMessage());\n }\n }\n\n @Override\n public void onServiceDisconnected(ComponentName name) {\n serviceRawBT = null;\n handler.postDelayed(()-> bindRawBT(false),5000);\n }\n\n }; final ICallback serviceCallback = new ICallback.Stub() {\n\n @Override\n public void onPrintSuccess(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintSuccess(finalJobId));\n }\n\n @Override\n public void onPrintError(String jobId,String errMessage) {\n final String finalJobId = jobId;\n final String finalMes = errMessage;\n handler.post(()-> handlePrintError(finalJobId,finalMes));\n }\n\n @Override\n public void onPrintCancel(String jobId) {\n final String finalJobId = jobId;\n handler.post(()-> handlePrintCancel(finalJobId));\n }\n\n @Override\n public void onProgress(String jobId, float p) {\n final String finalJobId = jobId;\n final float finalP = p;\n handler.post(()-> handlePrintProgress(finalJobId,finalP));\n }\n\n\n }; private final ActivityResultLauncher<String> mRequestPermission = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> bindRawBT(false));\n[DemoSdkActivity]", "score": 0.034482758620689655 }, { "title": "parent_class_file#type_identifiers#0.5", "text": "[AppCompatWithRawbtActivity] AppCompatActivity Handler Handler IRawBtPrintService ServiceConnection ServiceConnection ComponentName IBinder Exception ComponentName ICallback ICallback Stub String String String String String String String String String String SecurityException Exception ActivityResultLauncher String ActivityResultContracts RequestPermission Bundle RawbtPrintJob SecurityException Exception String String String String String Float\n[DemoSdkActivity]", "score": 0.03333333333333333 }, { "title": "parent_class_file#string_literals#0.5", "text": "[AppCompatWithRawbtActivity] \n[DemoSdkActivity]", "score": 0.03225806451612903 }, { "title": "child_class_file#string_literals#0.5", "text": "", "score": 0.03125 }, { "title": "import_of_similar_name_file#identifiers#0.5", "text": "", "score": 0.030303030303030304 }, { "title": "import_of_similar_name_file#method_names_and_bodies#0.5", "text": "", "score": 0.029411764705882353 }, { "title": "import_file#identifiers#0.5", "text": "", "score": 0.02857142857142857 }, { "title": "import_file#method_names_and_bodies#0.5", "text": "", "score": 0.027777777777777776 }, { "title": "import_of_similar_name_file#field_declarations#0.5", "text": "", "score": 0.02702702702702703 }, { "title": "import_of_similar_name_file#method_names#0.5", "text": "", "score": 0.02631578947368421 }, { "title": "import_of_similar_name_file#string_literals#0.5", "text": "", "score": 0.02564102564102564 }, { "title": "import_of_sibling_file#identifiers#0.5", "text": "", "score": 0.025 }, { "title": "import_of_sibling_file#method_names_and_bodies#0.5", "text": "", "score": 0.024390243902439025 }, { "title": "import_file#field_declarations#0.5", "text": "", "score": 0.023809523809523808 }, { "title": "import_file#method_names#0.5", "text": "", "score": 0.023255813953488372 }, { "title": "import_file#string_literals#0.5", "text": "", "score": 0.022727272727272728 }, { "title": "import_of_sibling_file#method_names#0.5", "text": "", "score": 0.022222222222222223 }, { "title": "import_of_sibling_file#field_declarations#0.5", "text": "", "score": 0.021739130434782608 }, { "title": "import_of_similar_name_file#type_identifiers#0.5", "text": "", "score": 0.02127659574468085 }, { "title": "import_file#type_identifiers#0.5", "text": "", "score": 0.020833333333333332 }, { "title": "import_of_sibling_file#string_literals#0.5", "text": "", "score": 0.02040816326530612 }, { "title": "import_of_sibling_file#type_identifiers#0.5", "text": "", "score": 0.02 }, { "title": "import_of_child_class_file#identifiers#0.5", "text": "", "score": 0.0196078431372549 }, { "title": "import_of_child_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.019230769230769232 }, { "title": "import_of_child_class_file#method_names#0.5", "text": "", "score": 0.018867924528301886 }, { "title": "import_of_child_class_file#field_declarations#0.5", "text": "", "score": 0.018518518518518517 }, { "title": "import_of_child_class_file#type_identifiers#0.5", "text": "", "score": 0.01818181818181818 }, { "title": "import_of_child_class_file#string_literals#0.5", "text": "", "score": 0.017857142857142856 }, { "title": "child_class_file#field_declarations#0.5", "text": "", "score": 0.017543859649122806 }, { "title": "import_of_parent_class_file#identifiers#0.5", "text": "", "score": 0.017241379310344827 }, { "title": "import_of_parent_class_file#method_names_and_bodies#0.5", "text": "", "score": 0.01694915254237288 }, { "title": "import_of_parent_class_file#type_identifiers#0.5", "text": "", "score": 0.016666666666666666 }, { "title": "import_of_parent_class_file#field_declarations#0.5", "text": "", "score": 0.01639344262295082 }, { "title": "import_of_parent_class_file#string_literals#0.5", "text": "", "score": 0.016129032258064516 }, { "title": "import_of_parent_class_file#method_names#0.5", "text": "", "score": 0.015873015873015872 } ]