Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

New class in MyStringAdapter.

Hello experts, I try implement new class RfidTagReaderAPI in MyStringAdapter, but I dint know if I do it correct, after installing the application in devices with new class my application is crash, why?

/*

* MyStringEditAdapter.java

*/

package com.sap.mobile.platform.client.openui.extensions;

import android.content.Context;

import android.graphics.Color;

import android.view.Gravity;

import android.view.View;

import android.widget.EditText;

import com.getac.lib.rfidreader.RfidTagReaderAPI; //LR

import com.sap.mobile.platform.client.openui.adapters.StringEditAdapter;

import com.sap.mobile.platform.client.openui.models.StringEditModel;

import com.sap.mobile.platform.client.openui.utils.Helpers;

import com.sap.mobile.platform.core.openui.AutosizeBehavior;

public class MyStringEditAdapter extends StringEditAdapter

{

    /** Core model */

StringEditModel _model;

    /** App context */

    Context _context;

    /** Text view */

    EditText _textView;

    /** Allows auto height */

    boolean _autoHeight;

    /** Carriage return */

    boolean _carriageReturn;

    /** Word Wrapt */

    boolean _wordWrap;

  

    private EditText mTV;

    /*

     * (non-Javadoc)

     *

     * @see

     * com.sap.mobile.platform.client.openui.adapters.StringDisplayAdapter#initialize(com.sap.mobile.platform.client

     * .openui.models.StringDisplayModel, android.content.Context)

     */

@Override

    public void initialize(StringEditModel model, Context context)

    {

_model = model;

_context = context;

_carriageReturn = _model.isCarriageReturnAllowed();

_wordWrap = _model.isWordWrapAllowed();

_autoHeight = _model.isAutosizeSupported();

    }

    /*

     * (non-Javadoc)

     *

     * @see com.sap.mobile.platform.client.openui.adapters.FieldAdapter#getView()

     */

@Override

    public View getView()

    {

_textView = new EditText(_context);

_textView.setText(_model.getValue());

//_textView.setText("AS242ASD");//LR

_textView.setText(RfidTagReaderAPI.Read15693TagID());//LR

_textView.setTextColor(Color.RED); //LR

_textView.setGravity(Gravity.CENTER_VERTICAL);

if (!canHandleAutosizing())

{

_textView.setSingleLine();

}

_textView.setOnFocusChangeListener(new View.OnFocusChangeListener()

{

@Override

public void onFocusChange(View v, boolean hasFocus)

{

if (!hasFocus)

{

  _model.processInput(_textView.getText()+"AS242342".toString());//LR

}

}// end onFocuschange

});// end setOnFocusChangeListener

return _textView;

    }

    /**

     * Can we handle autosizing?

     *

     * @return if we can handle autosizing

     */

    public boolean canHandleAutosizing()

    {

if (_autoHeight && (_wordWrap || _carriageReturn))

{

return true;

}

return false;

    }

@Override

    public AutosizeBehavior getAutosizeBehavior()

    {

if (canHandleAutosizing())

{

return AutosizeBehavior.Autosize_FillVisible;

}

return AutosizeBehavior.Autosize_None;

    }

    public void valueChanged(String[] args)

    //public void valueChanged(String value) //LR

    {

String model = "AO837248927";//LR

_textView.setText(_model.getValue()+"");//LR

    }

@Override

    public boolean isAgentryDisplayingLabel()

    {

return true;

    }

@Override

    public int getContentHeightForAutosizing(int width)

    {

int height = Helpers.AutosizeUtils.heightForMultiLineText(_textView, width, _carriageReturn, _wordWrap);

return height;

    }

  

    public void onResume() {

        super.onResume();

        RfidTagReaderAPI.InitRFIDReader();

        RfidTagReaderAPI.Set14443ATagModel();

    }

    @Override

    public void onPause() {

        super.onPause();

        RfidTagReaderAPI.FinalRFIDReader();

    }

}

Tags edited by: Michael Appleby

Tags:
Former Member
Former Member replied

Hi, solution was, extension initialize method of the RFID reader.

BR

Lukas

1 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question