Example usage for android.widget TextView invalidate

List of usage examples for android.widget TextView invalidate

Introduction

In this page you can find the example usage for android.widget TextView invalidate.

Prototype

public void invalidate() 

Source Link

Document

Invalidate the whole view.

Usage

From source file:Main.java

/**
 * Sets the text color for a {@link TextView}.
 *
 * @param textview   text view instance/* w w  w  .jav a  2 s  .  co m*/
 * @param argb  text RGB color with alpha
 */
public static void setTextColor(TextView textview, int argb) {
    textview.setTextColor(argb);
    textview.invalidate();
}

From source file:Main.java

/**
 * {@link TextView} background color setter.  Generally, the caller will
 * not pass {@link Component#COLOR_DEFAULT}, instead substituting in the
 * appropriate color.//from   w  w  w  . j av  a  2s.  co  m
 *
 * @param textview   text view instance
 * @param argb  background RGB color with alpha
 */
public static void setBackgroundColor(TextView textview, int argb) {
    textview.setBackgroundColor(argb);
    textview.invalidate();
}

From source file:Main.java

/**
 * Enables a {@link TextView}./*from  w ww  .j a v a2 s.  c om*/
 *
 * @param textview   text view instance
 * @param enabled  {@code true} for enabled, {@code false} disabled
 */
public static void setEnabled(TextView textview, boolean enabled) {
    textview.setEnabled(enabled);
    textview.invalidate();
}

From source file:Main.java

public static void updateInfoPanel(TextView infoPanel, int color, String message) {
    if (infoPanel != null) {
        infoPanel.setTextColor(color);//  w w  w .  java  2s . c om
        infoPanel.setText(message);
        infoPanel.setSelected(true);
        infoPanel.invalidate();
    }
}

From source file:Main.java

public static void updateStatusBar(TextView statusBarMain, int color, String message) {
    if (statusBarMain != null) {
        statusBarMain.setTextColor(color);
        statusBarMain.setText(message);//from   ww  w  .  j a  v a  2  s .co  m
        statusBarMain.setSelected(true);
        statusBarMain.invalidate();
    }
}

From source file:com.inmobi.ultrapush.InfoRecActivity.java

@Override
protected void onResume() {
    super.onResume();
    TextView tv = (TextView) findViewById(R.id.textview_info_rec);
    tv.setMovementMethod(new ScrollingMovementMethod());

    tv.setText("Testing..."); // TODO: No use...
    tv.invalidate();

    // Show supported sample rate and corresponding minimum buffer size.
    String[] requested = new String[] { "8000", "11025", "16000", "22050", "32000", "44100", "48000", "96000" };
    String st = "sampleRate minBufSize\n";
    ArrayList<String> validated = new ArrayList<String>();
    for (String s : requested) {
        int rate = Integer.parseInt(s);
        int minBufSize = AudioRecord.getMinBufferSize(rate, AudioFormat.CHANNEL_IN_MONO,
                AudioFormat.ENCODING_PCM_16BIT);
        if (minBufSize != AudioRecord.ERROR_BAD_VALUE) {
            validated.add(s);//w ww.ja v a 2  s.  co  m
            st += s + "  \t" + Integer.toString(minBufSize) + "\n";
        }
    }
    requested = validated.toArray(new String[0]);

    tv.setText(st);
    tv.invalidate();

    // Test audio source
    String[] audioSourceString = new String[] { "DEFAULT", "MIC", "VOICE_UPLINK", "VOICE_DOWNLINK",
            "VOICE_CALL", "CAMCORDER", "VOICE_RECOGNITION" };
    int[] audioSourceId = new int[] { MediaRecorder.AudioSource.DEFAULT, // Default audio source
            MediaRecorder.AudioSource.MIC, // Microphone audio source
            MediaRecorder.AudioSource.VOICE_UPLINK, // Voice call uplink (Tx) audio source
            MediaRecorder.AudioSource.VOICE_DOWNLINK, // Voice call downlink (Rx) audio source
            MediaRecorder.AudioSource.VOICE_CALL, // Voice call uplink + downlink audio source
            MediaRecorder.AudioSource.CAMCORDER, // Microphone audio source with same orientation as camera if available, the main device microphone otherwise (apilv7)
            MediaRecorder.AudioSource.VOICE_RECOGNITION, // Microphone audio source tuned for voice recognition if available, behaves like DEFAULT otherwise. (apilv7)
            //            MediaRecorder.AudioSource.VOICE_COMMUNICATION, // Microphone audio source tuned for voice communications such as VoIP. It will for instance take advantage of echo cancellation or automatic gain control if available. It otherwise behaves like DEFAULT if no voice processing is applied. (apilv11)
            //            MediaRecorder.AudioSource.REMOTE_SUBMIX,       // Audio source for a submix of audio streams to be presented remotely. (apilv19)
    };
    tv.append("\n-- Audio Source Test --");
    for (String s : requested) {
        int sampleRate = Integer.parseInt(s);
        int recBufferSize = AudioRecord.getMinBufferSize(sampleRate, AudioFormat.CHANNEL_IN_MONO,
                AudioFormat.ENCODING_PCM_16BIT);
        tv.append("\n(" + Integer.toString(sampleRate) + "Hz, MONO, 16BIT)\n");
        for (int iass = 0; iass < audioSourceId.length; iass++) {
            st = "";
            // wait for AudioRecord fully released...
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            AudioRecord record;
            record = new AudioRecord(audioSourceId[iass], sampleRate, AudioFormat.CHANNEL_IN_MONO,
                    AudioFormat.ENCODING_PCM_16BIT, recBufferSize);
            if (record.getState() == AudioRecord.STATE_INITIALIZED) {
                st += audioSourceString[iass] + " successed";
                int as = record.getAudioSource();
                if (as != audioSourceId[iass]) {
                    int i = 0;
                    while (i < audioSourceId.length) {
                        if (as == audioSourceId[iass]) {
                            break;
                        }
                        i++;
                    }
                    if (i >= audioSourceId.length) {
                        st += "(auto set to \"unknown source\")";
                    } else {
                        st += "(auto set to " + audioSourceString[i] + ")";
                    }
                }
                st += "\n";
            } else {
                st += audioSourceString[iass] + " failed\n";
            }
            record.release();
            record = null;
            tv.append(st);
            tv.invalidate();
        }
    }

}

From source file:com.iiordanov.bVNC.dialogs.GetTextFragment.java

private void ensureMatchingDismissOnConfirm(Button buttonConfirm, final EditText textBox1,
        final EditText textBox2, final TextView error) {
    buttonConfirm.setOnClickListener(new OnClickListener() {
        @Override//  w w w. ja  va2 s.  c om
        public void onClick(View v) {
            if (textBox1.getText().toString().equals(textBox2.getText().toString())) {
                getDialog().dismiss();
            } else {
                error.setText(errorNum);
                error.setVisibility(View.VISIBLE);
                error.invalidate();
            }
        }
    });

    textBox1.addTextChangedListener(new TextMatcher());
    textBox2.addTextChangedListener(new TextMatcher());
}

From source file:us.shandian.blacklight.ui.main.MainActivity.java

@Override
public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
    if ((parent != mOther || position == 0) && mLastChoice != null) {
        mLastChoice.getPaint().setFakeBoldText(false);
        mLastChoice.invalidate();/*from  w w  w  .j a  va 2 s  .co  m*/
    }

    if (mGroups != null && mGroups.getSize() > 0 && (parent != mOther || position != 1)) {
        getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
        getActionBar().setDisplayShowTitleEnabled(true);
    }

    if (parent == mMy) {
        TextView tv = (TextView) view;
        tv.getPaint().setFakeBoldText(true);
        tv.invalidate();
        mLastChoice = tv;
        mNext = position;
        if (mFragments[position] != null) {
            tv.postDelayed(new Runnable() {
                @Override
                public void run() {
                    try {
                        switchTo(position);
                    } catch (Exception e) {

                    }

                    if (position == 0 && mGroups != null && mGroups.getSize() > 0) {
                        getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
                        getActionBar().setDisplayShowTitleEnabled(false);
                        updateActionSpinner();
                    }
                }
            }, 400);
        }
    } else if (parent == mAtMe) {
        TextView tv = (TextView) view;
        tv.getPaint().setFakeBoldText(true);
        tv.invalidate();
        mLastChoice = tv;
        mNext = position + 4;
        if (mFragments[4 + position] != null) {
            tv.postDelayed(new Runnable() {
                @Override
                public void run() {
                    try {
                        switchTo(4 + position);
                    } catch (Exception e) {

                    }
                }
            }, 400);
        }
    } else if (parent == mOther) {
        switch (position) {
        case 0: {
            mNext = 6;
            view.postDelayed(new Runnable() {
                @Override
                public void run() {
                    try {
                        switchTo(6);
                    } catch (Exception e) {

                    }
                }
            }, 400);
            break;
        }
        case 1: {
            Intent i = new Intent();
            i.setAction(Intent.ACTION_MAIN);
            i.setClass(this, SettingsActivity.class);
            startActivity(i);
            break;
        }
        case 2: {
            mLoginCache.logout();
            Intent i = new Intent();
            i.setAction(Intent.ACTION_MAIN);
            i.setClass(this, EntryActivity.class);
            startActivity(i);
            finish();
            break;
        }
        }
    }

    mDrawer.closeDrawer(mDrawerGravity);
}

From source file:ru.adios.budgeter.widgets.DataTableLayout.java

private void selectOrderByColumn(TextView col) {
    if (selectedColumn != null) {
        selectedColumn.setSelected(false);
        selectedColumn.invalidate();/*from   ww  w .  j  a  v  a  2s.com*/
    }
    col.setSelected(true);
    col.invalidate();
    selectedColumn = col;
}

From source file:com.roamprocess1.roaming4world.ui.messages.ConversationsListFragment.java

@SuppressLint("NewApi")
@Override/*from   w  w  w  .  j a v a 2  s .  c  o  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
    View v = inflater.inflate(R.layout.message_list_fragment, container, false);
    LinearLayout progressContainer = (LinearLayout) v.findViewById(R.id.progressContainer);

    prefs = getActivity().getSharedPreferences("com.roamprocess1.roaming4world", Context.MODE_PRIVATE);
    stored_chatuserNumber = "com.roamprocess1.roaming4world.stored_chatuserNumber";
    stored_user_country_code = "com.roamprocess1.roaming4world.user_country_code";

    stored_account_register_status = "com.roamprocess1.roaming4world.account_register_status";
    preRegValue = prefs.getString(stored_account_register_status, "Connecting");
    System.out.println("oncreate prefValue" + preRegValue);

    LinearLayout onlinelayout = (LinearLayout) v.findViewById(R.id.onlineStatus);
    LinearLayout header_onlinelayout = (LinearLayout) v.findViewById(R.id.ll_dialer_onlineStatus);

    TextView status_register_account = (TextView) v.findViewById(R.id.status);

    ConnectivityManager connMgr1 = (ConnectivityManager) getActivity()
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo1 = connMgr1.getActiveNetworkInfo();
    if (networkInfo1 != null && networkInfo1.isConnected()) {

        if (status_register_account != null) {
            if (preRegValue.equals("Online")) {
                status_register_account.invalidate();
                onlinelayout.setBackgroundColor(Color.parseColor("#8CC63F"));
                status_register_account.setText("Online");
                status_register_account.invalidate();
                onlinelayout.setVisibility(LinearLayout.GONE);
                header_onlinelayout.setBackgroundColor(Color.parseColor("#8CC63F"));
            } else if (preRegValue.equals("Connecting")) {
                onlinelayout.setBackgroundColor(Color.parseColor("#FFA500"));
                status_register_account.setText("Connecting");
                status_register_account.invalidate();
                onlinelayout.invalidate();
                header_onlinelayout.setBackgroundColor(Color.parseColor("#FFA500"));
                onlinelayout.setVisibility(LinearLayout.GONE);
            }
        }
    } else {
        System.out.println("updateRegistrationsState() : No network");
        status_register_account.invalidate();
        onlinelayout.setBackgroundColor(Color.parseColor("#EB3D35"));
        status_register_account.setText("No Internet Connection");
        status_register_account.invalidate();
        onlinelayout.invalidate();
        onlinelayout.setVisibility(LinearLayout.GONE);
        header_onlinelayout.setBackgroundColor(Color.parseColor("#EB3D35"));

    }

    if (CurrentFragment.progressContainerLayout == false) {
        progressContainer.setVisibility(LinearLayout.GONE);
    }
    CurrentFragment.progressContainerLayout = true;

    ListView lv = (ListView) v.findViewById(android.R.id.list);

    View.OnClickListener addClickButtonListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            System.out.println("conversationsListFragment.java in oncreateview in onClick listener");
            onClickAddMessage();
        }
    };

    // Header view
    mHeaderView = (ViewGroup) inflater.inflate(R.layout.conversation_list_item, lv, false);
    ((TextView) mHeaderView.findViewById(R.id.from)).setText(R.string.new_message);
    ((TextView) mHeaderView.findViewById(R.id.subject)).setText(R.string.create_new_message);
    mHeaderView.findViewById(R.id.quick_contact_photo).setVisibility(View.GONE);
    mHeaderView.setOnClickListener(addClickButtonListener);
    // Empty view
    Button bt = (Button) v.findViewById(android.R.id.empty);

    //  bt.setOnClickListener(addClickButtonListener);
    bt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(getActivity(), MessageSipUri.class);
            getActivity().startActivity(intent);
        }
    });
    /*
    View vv = getActivity().getActionBar().getCustomView();
    imgButton_Chat = (ImageButton) vv.findViewById(R.id.imgRightMenu_chat);
    imgRightMenu = (ImageButton) vv.findViewById(R.id.imgRightMenu);
            
            
            
    imgButton_Chat.setOnClickListener(new View.OnClickListener() {
             
     @Override
     public void onClick(View v) {
    // TODO Auto-generated method stub
    onClickAddMessage();
     }
    });*/

    return v;
}