Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.List;

import android.text.InputType;

import android.view.View;

import android.widget.TextView;

public class Main {
    public static List<String> elementEntryTypes(View view) {
        if (view instanceof TextView) {
            TextView textView = (TextView) view;
            return mapTextViewInputTypes(textView.getInputType());
        }
        return null;

    }

    public static List<String> mapTextViewInputTypes(int inputType) {
        List<String> inputTypes = new ArrayList<String>();
        if (inputTypeHasTrait(inputType, InputType.TYPE_TEXT_VARIATION_PASSWORD)
                || inputTypeHasTrait(inputType, InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD)) {
            inputTypes.add("password");
        }
        if (inputTypeHasTrait(inputType, InputType.TYPE_CLASS_NUMBER)) {
            inputTypes.add("numeric");
        }
        inputTypes.add(String.valueOf(inputType));

        return inputTypes;
    }

    private static boolean inputTypeHasTrait(int inputType, int inputTypeTrait) {
        return (inputType & inputTypeTrait) != 0;
    }
}