Example usage for android.graphics Typeface createFromAsset

List of usage examples for android.graphics Typeface createFromAsset

Introduction

In this page you can find the example usage for android.graphics Typeface createFromAsset.

Prototype

public static Typeface createFromAsset(AssetManager mgr, String path) 

Source Link

Document

Create a new typeface from the specified font data.

Usage

From source file:com.corporatetaxi.TaxiOntheWay_Activity.java

private void initiatePopupWindowsendmesage() {
    try {// ww w .j a v  a2s . c  o m
        dialog = new Dialog(TaxiOntheWay_Activity.this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // before
        dialog.setContentView(R.layout.sendmesssage_popup);

        Button mbtn_sendmesssage = (Button) dialog.findViewById(R.id.btn_acceptor);
        Button mbtn_cancel = (Button) dialog.findViewById(R.id.btn_cancel);
        rd4 = (RadioButton) dialog.findViewById(R.id.radioButton1);
        rd5 = (RadioButton) dialog.findViewById(R.id.radioButton2);
        rd6 = (RadioButton) dialog.findViewById(R.id.radioButton3);
        mcross = (ImageButton) dialog.findViewById(R.id.cross);
        txt_header = (TextView) dialog.findViewById(R.id.popup_text);
        mcross.setOnClickListener(cancle_btn_click_listener);
        mbtn_cancel.setOnClickListener(cancle_btn_click_listener);
        Typeface tf = Typeface.createFromAsset(this.getAssets(), "Montserrat-Regular.ttf");
        rd4.setTypeface(tf);
        rd5.setTypeface(tf);
        rd6.setTypeface(tf);
        mbtn_sendmesssage.setTypeface(tf);
        txt_header.setTypeface(tf);
        mbtn_cancel.setTypeface(tf);
        mbtn_sendmesssage.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                if (rd4.isChecked()) {
                    sendmessage = getResources().getString(R.string.prompt_message_one);

                } else if (rd5.isChecked()) {
                    sendmessage = getResources().getString(R.string.prompt_message_two);

                } else if (rd6.isChecked()) {
                    sendmessage = getResources().getString(R.string.prompt_message_three);

                }

                Allbeans allbeans = new Allbeans();

                allbeans.setSendmessage(sendmessage);

                new SendmessageAsynch(allbeans).execute();

            }
        });
        dialog.show();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.readium.sdk.android.biblemesh.WebViewActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.web_view, menu);

    MenuItem mo_previous = menu.findItem(R.id.mo_previous);
    MenuItem mo_next = menu.findItem(R.id.mo_next);
    MenuItem mo_play = menu.findItem(R.id.mo_play);
    MenuItem mo_pause = menu.findItem(R.id.mo_pause);

    // show menu only when its reasonable

    mo_previous.setVisible(mIsMoAvailable);
    mo_next.setVisible(mIsMoAvailable);/*from  w  w  w.  j  ava  2 s .  com*/

    if (mIsMoAvailable) {
        mo_play.setVisible(!mIsMoPlaying);
        mo_pause.setVisible(mIsMoPlaying);
    }
    Typeface face = Typeface.createFromAsset(getAssets(), "fonts/fontawesome-webfont.ttf");
    TextDrawable faIcon = new TextDrawable(this);
    faIcon.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    faIcon.setTextAlign(Layout.Alignment.ALIGN_CENTER);
    faIcon.setTextColor(Color.parseColor("#ffffff"));
    faIcon.setTypeface(face);
    faIcon.setText(getResources().getText(R.string.fa_cog));
    TextDrawable faIcon2 = new TextDrawable(this);
    faIcon2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    faIcon2.setTextAlign(Layout.Alignment.ALIGN_CENTER);
    faIcon2.setTextColor(Color.parseColor("#ffffff"));
    faIcon2.setTypeface(face);
    faIcon2.setText(getResources().getText(R.string.fa_toc));
    MenuItem menuItem = menu.findItem(R.id.settings);
    menuItem.setIcon(faIcon);
    MenuItem menuItem2 = menu.findItem(R.id.toc);
    menuItem2.setIcon(faIcon2);

    /*MenuItem menuItem3 = menu.findItem(R.id.toc);
    item.setOnMenuItemClickListener
    (
          new MenuItem.OnMenuItemClickListener ()
          {
             public boolean onMenuItemClick(MenuItem item)
             { return (showDirectory(item)); }
          }
    );*/

    return true;
}

From source file:com.usertaxi.TaxiOntheWay_Activity.java

private void initiatePopupWindowcanceltaxi() {
    try {/*from  ww  w  .  j a v a  2s.  co m*/
        dialog = new Dialog(TaxiOntheWay_Activity.this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // before
        dialog.setContentView(R.layout.canceltaxi_popup);
        cross = (ImageButton) dialog.findViewById(R.id.cross);
        cross.setOnClickListener(cancle_btn_click_listener);
        rd1 = (RadioButton) dialog.findViewById(R.id.radioButton);
        rd2 = (RadioButton) dialog.findViewById(R.id.radioButton2);
        rd3 = (RadioButton) dialog.findViewById(R.id.radioButton3);
        btn_cancel = (Button) dialog.findViewById(R.id.btn_acceptor);
        TextView txt = (TextView) dialog.findViewById(R.id.textView);
        textheader = (TextView) dialog.findViewById(R.id.popup_text);
        Typeface tf = Typeface.createFromAsset(this.getAssets(), "Montserrat-Regular.ttf");
        rd1.setTypeface(tf);
        rd2.setTypeface(tf);
        rd3.setTypeface(tf);
        btn_cancel.setTypeface(tf);
        txt.setTypeface(tf);
        textheader.setTypeface(tf);
        btn_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (rd1.isChecked()) {
                    canceltaxirequest = getResources().getString(R.string.prompt_canceltaxione);

                } else if (rd2.isChecked()) {
                    canceltaxirequest = getResources().getString(R.string.prompt_cancel_reason_two);

                } else if (rd3.isChecked()) {
                    canceltaxirequest = getResources().getString(R.string.prompt_cancel_reason_three);

                }

                Allbeans allbeans = new Allbeans();
                allbeans.setCanceltaxirequest(canceltaxirequest);

                new CancelTaxiAsynch(allbeans).execute();

            }
        });

        dialog.show();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.terraremote.terrafieldreport.OpenGroundReport.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.open_ground_layout);
    ButterKnife.bind(this);

    loadSharedPreferences();/*from w  w  w  .j a va  2 s  . c o m*/

    Typeface customTypeface = Typeface.createFromAsset(getAssets(), "Raleway-Medium.ttf");
    TextView open_ground_text_font = findViewById(R.id.open_ground_text);
    open_ground_text_font.setTypeface(customTypeface);

    //        final DecimalFormat df = new DecimalFormat("0.00000");
    // Grab the current date and update the string variable 'userSelectedDateGround' with its value.
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    showDate.setText(sdf.format(new Date()));
    submissionDate = sdf.format(new Date());

    // get the defined string array of field team names
    ArrayAdapter<String> enterNameAdapter = new ArrayAdapter<>(this,
            android.R.layout.simple_dropdown_item_1line,
            getResources().getStringArray(R.array.TerraFieldTeamNames));
    AutoCompleteTextView enterNameTextView = (AutoCompleteTextView) mName;
    //set adapter for the auto complete fields
    enterNameTextView.setAdapter(enterNameAdapter);
    // specify the minimum type of characters before drop-down list is shown
    enterNameTextView.setThreshold(1);
    // comma to separate the different names
    enterNameTextView.setAdapter(enterNameAdapter);

    // get the defined string array of field team names
    ArrayAdapter<String> fieldTeamNameAdapter = new ArrayAdapter<>(this,
            android.R.layout.simple_dropdown_item_1line,
            getResources().getStringArray(R.array.TerraFieldTeamNames));
    MultiAutoCompleteTextView fieldTeamNameTextView = mColleagues;
    //set adapter for the auto complete fields
    fieldTeamNameTextView.setAdapter(fieldTeamNameAdapter);
    // specify the minimum type of characters before drop-down list is shown
    fieldTeamNameTextView.setThreshold(1);
    // comma to separate the different names
    fieldTeamNameTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());

    // get the defined string array of helicopter color names
    ArrayAdapter<String> vehicleColorAdapter = new ArrayAdapter<>(this,
            android.R.layout.simple_dropdown_item_1line, getResources().getStringArray(R.array.vehicle_colors));
    AutoCompleteTextView vehicleColorsTextView = (AutoCompleteTextView) mVehicleColour;
    //set adapter for the auto complete fields
    vehicleColorsTextView.setAdapter(vehicleColorAdapter);
    // specify the minimum type of characters before drop-down list is shown
    vehicleColorsTextView.setThreshold(1);
    // set adapter
    vehicleColorsTextView.setAdapter(vehicleColorAdapter);

    // get the defined string array of vehicle makes
    ArrayAdapter<String> vehicleMakeAdapter = new ArrayAdapter<>(this,
            android.R.layout.simple_dropdown_item_1line, getResources().getStringArray(R.array.vehicle_make));
    AutoCompleteTextView vehicleMakeTextView = (AutoCompleteTextView) mVehicleMake;
    //set adapter for the auto complete fields
    vehicleMakeTextView.setAdapter(vehicleMakeAdapter);
    // specify the minimum type of characters before drop-down list is shown
    vehicleMakeTextView.setThreshold(1);
    // set adapter
    vehicleMakeTextView.setAdapter(vehicleMakeAdapter);

    // get the defined string array of car rental agencies
    ArrayAdapter<String> rentalAgencyAdapter = new ArrayAdapter<>(this,
            android.R.layout.simple_dropdown_item_1line,
            getResources().getStringArray(R.array.rental_agencies));
    AutoCompleteTextView rentalAgencyTv = (AutoCompleteTextView) mRentalAgency;
    //set adapter for the auto complete fields
    rentalAgencyTv.setAdapter(rentalAgencyAdapter);
    // specify the minimum type of characters before drop-down list is shown
    rentalAgencyTv.setThreshold(1);
    // set adapter
    rentalAgencyTv.setAdapter(rentalAgencyAdapter);

    // get the defined string array of vehicle operator names
    ArrayAdapter<String> vehicleOperatorNameAdapter = new ArrayAdapter<>(this,
            android.R.layout.simple_dropdown_item_1line,
            getResources().getStringArray(R.array.check_in_contact_data_checker_names));
    AutoCompleteTextView vehicleOperatorNameTextView = (AutoCompleteTextView) mVehicleOperatorName;
    //set adapter for the auto complete fields
    vehicleOperatorNameTextView.setAdapter(vehicleOperatorNameAdapter);
    // specify the minimum type of characters before drop-down list is shown
    vehicleOperatorNameTextView.setThreshold(1);
    // set adapter
    vehicleOperatorNameTextView.setAdapter(vehicleOperatorNameAdapter);

}

From source file:com.if3games.chessonline.DroidFish.java

/** Called when the activity is first created. */
@Override//from   ww  w  . j a  va  2s  . c o m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    int isGMS = getIntent().getExtras().getInt("gms");
    if (isGMS != 1) {
        isSinglePlayer = true;
    } else {
        isSinglePlayer = false;

        GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this);
        builder.addApi(Games.API).addApi(Plus.API).addApi(AppStateManager.API).addScope(Games.SCOPE_GAMES)
                .addScope(Plus.SCOPE_PLUS_LOGIN).addScope(AppStateManager.SCOPE_APP_STATE);
        mClient = builder.build();

        loadLocal();

        if (isSignedIn()) {
            //onFetchPlayerScoreAndAchive();
            //displayPlayerNameScoreRank();
            //Toast.makeText(this, "I Connected", Toast.LENGTH_SHORT).show();
        }
    }

    Pair<String, String> pair = getPgnOrFenIntent();
    String intentPgnOrFen = pair.first;
    String intentFilename = pair.second;

    createDirectories();

    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    settings = PreferenceManager.getDefaultSharedPreferences(this);
    settings.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
            try {
                handlePrefsChange();
            } catch (Exception e) {
                // TODO: handle exception
            }
        }
    });

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    setWakeLock(false);
    wakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "droidfish");
    wakeLock.setReferenceCounted(false);

    custom1ButtonActions = new ButtonActions("custom1", CUSTOM1_BUTTON_DIALOG, R.string.select_action);
    custom2ButtonActions = new ButtonActions("custom2", CUSTOM2_BUTTON_DIALOG, R.string.select_action);
    custom3ButtonActions = new ButtonActions("custom3", CUSTOM3_BUTTON_DIALOG, R.string.select_action);

    figNotation = Typeface.createFromAsset(getAssets(), "fonts/DroidFishChessNotationDark.otf");
    setPieceNames(PGNOptions.PT_LOCAL);
    //requestWindowFeature(Window.FEATURE_NO_TITLE);
    initUI();

    gameTextListener = new PgnScreenText(pgnOptions);
    if (ctrl != null)
        ctrl.shutdownEngine();
    ctrl = new DroidChessController(this, gameTextListener, pgnOptions);
    egtbForceReload = true;
    readPrefs();
    TimeControlData tcData = new TimeControlData();
    tcData.setTimeControl(timeControl, movesPerSession, timeIncrement);
    if (isSinglePlayer) {
        myTurn = true;
        ctrl.newGame(gameMode, tcData);
        {
            byte[] data = null;
            int version = 1;
            if (savedInstanceState != null) {
                data = savedInstanceState.getByteArray("gameState");
                version = savedInstanceState.getInt("gameStateVersion", version);
            } else {
                String dataStr = settings.getString("gameState", null);
                version = settings.getInt("gameStateVersion", version);
                if (dataStr != null)
                    data = strToByteArr(dataStr);
            }
            if (data != null)
                ctrl.fromByteArray(data, version);
        }
        ctrl.setGuiPaused(true);
        ctrl.setGuiPaused(false);
        ctrl.startGame();
        //startNewGame(0);
        if (intentPgnOrFen != null) {
            try {
                ctrl.setFENOrPGN(intentPgnOrFen);
                setBoardFlip(true);
            } catch (ChessParseError e) {
                // If FEN corresponds to illegal chess position, go into edit board mode.
                try {
                    TextIO.readFEN(intentPgnOrFen);
                } catch (ChessParseError e2) {
                    if (e2.pos != null)
                        startEditBoard(intentPgnOrFen);
                }
            }
        } else if (intentFilename != null) {
            if (intentFilename.toLowerCase(Locale.US).endsWith(".fen")
                    || intentFilename.toLowerCase(Locale.US).endsWith(".epd"))
                loadFENFromFile(intentFilename);
            else
                loadPGNFromFile(intentFilename);
        }
    } else {
        int rnd = new Random().nextInt(2);
        startMultiplayerGameMode(rnd);
    }
}

From source file:com.brandao.tictactoe.board.BoardFragment.java

public void setTheme(View view) {
    if (view != null) {
        ((LinearLayout) view.findViewById(R.id.board_id)).setBackgroundResource(R.drawable.board);
    }//from   ww w.  j a v a  2s  . c  o m

    Typeface titleFont = Typeface.createFromAsset(getActivity().getAssets(), "fonts/DroidSans-Bold.ttf");

    mPlayerOneNameDisplay.setTypeface(titleFont);
    mPlayerTwoNameDisplay.setTypeface(titleFont);
}

From source file:com.apptentive.android.sdk.util.Util.java

public static void replaceDefaultFont(Context context, String fontFilePath) {
    final Typeface newTypeface = Typeface.createFromAsset(context.getAssets(), fontFilePath);

    TypedValue tv = new TypedValue();
    String staticTypefaceFieldName = null;
    Map<String, Typeface> newMap = null;

    Resources.Theme apptentiveTheme = context.getResources().newTheme();
    ApptentiveInternal.getInstance().updateApptentiveInteractionTheme(apptentiveTheme, context);

    if (apptentiveTheme == null) {
        return;//w  w  w  .j  av  a2  s.c om
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (apptentiveTheme.resolveAttribute(R.attr.apptentiveFontFamilyDefault, tv, true)) {
            newMap = new HashMap<String, Typeface>();
            newMap.put(tv.string.toString(), newTypeface);
        }
        if (apptentiveTheme.resolveAttribute(R.attr.apptentiveFontFamilyMediumDefault, tv, true)) {
            if (newMap == null) {
                newMap = new HashMap<String, Typeface>();
            }
            newMap.put(tv.string.toString(), newTypeface);
        }
        if (newMap != null) {
            try {
                final Field staticField = Typeface.class.getDeclaredField("sSystemFontMap");
                staticField.setAccessible(true);
                staticField.set(null, newMap);
            } catch (NoSuchFieldException e) {
                ApptentiveLog.e("Exception replacing system font", e);
            } catch (IllegalAccessException e) {
                ApptentiveLog.e("Exception replacing system font", e);
            }
        }
    } else {
        if (apptentiveTheme.resolveAttribute(R.attr.apptentiveTypefaceDefault, tv, true)) {
            staticTypefaceFieldName = "DEFAULT";
            if (tv.data == context.getResources().getInteger(R.integer.apptentive_typeface_monospace)) {
                staticTypefaceFieldName = "MONOSPACE";
            } else if (tv.data == context.getResources().getInteger(R.integer.apptentive_typeface_serif)) {
                staticTypefaceFieldName = "SERIF";
            } else if (tv.data == context.getResources().getInteger(R.integer.apptentive_typeface_sans)) {
                staticTypefaceFieldName = "SANS_SERIF";
            }
            try {
                final Field staticField = Typeface.class.getDeclaredField(staticTypefaceFieldName);
                staticField.setAccessible(true);
                staticField.set(null, newTypeface);
            } catch (NoSuchFieldException e) {
                ApptentiveLog.e("Exception replacing system font", e);
            } catch (IllegalAccessException e) {
                ApptentiveLog.e("Exception replacing system font", e);
            }
        }
    }
}

From source file:key.secretkey.crypto.PgpHandler.java

@Override
public void onBound(IOpenPgpService2 service) {
    Log.i("PGP", "ISBOUND!!");

    Bundle extra = getIntent().getExtras();
    final String operation = extra.getString("Operation");
    if (operation == null) {
        return;//from   www.jav  a 2 s. c om
    }
    if (operation.equals("DECRYPT")) {
        setContentView(R.layout.decrypt_layout);
        ((TextView) findViewById(R.id.crypto_password_file)).setText(extra.getString("NAME"));
        String path = extra.getString("FILE_PATH")
                .replace(PasswordStorage.getRepositoryDirectory(getApplicationContext()).getAbsolutePath(), "");
        String cat = new File(path).getParentFile().getName();

        ((TextView) findViewById(R.id.crypto_password_category)).setText(cat + "/");
        decryptAndVerify(new Intent());
    } else if (operation.equals("ENCRYPT")) {
        setContentView(R.layout.encrypt_layout);
        Typeface monoTypeface = Typeface.createFromAsset(getAssets(), "fonts/sourcecodepro.ttf");
        ((EditText) findViewById(R.id.crypto_password_edit)).setTypeface(monoTypeface);
        ((EditText) findViewById(R.id.crypto_extra_edit)).setTypeface(monoTypeface);
        String cat = extra.getString("FILE_PATH");
        cat = cat.replace(PasswordStorage.getRepositoryDirectory(getApplicationContext()).getAbsolutePath(),
                "");
        cat = cat + "/";
        ((TextView) findViewById(R.id.crypto_password_category)).setText(cat);
    } else if (operation.equals("GET_KEY_ID")) {
        getKeyIds(new Intent());

        //            setContentView(R.layout.key_id);
        //            if (!keyIDs.isEmpty()) {
        //                String keys = keyIDs.split(",").length > 1 ? keyIDs : keyIDs.split(",")[0];
        //                ((TextView) findViewById(R.id.crypto_key_ids)).setText(keys);
        //            }
    } else if (operation.equals("EDIT")) {
        setContentView(R.layout.decrypt_layout);
        ((TextView) findViewById(R.id.crypto_password_file)).setText(extra.getString("NAME"));
        String cat = new File(extra.getString("FILE_PATH")
                .replace(PasswordStorage.getRepositoryDirectory(getApplicationContext()).getAbsolutePath(), ""))
                        .getParentFile().getName();

        ((TextView) findViewById(R.id.crypto_password_category)).setText(cat + "/");
        edit(new Intent());
    } else if (operation.equals("SELECTFOLDER")) {
        setContentView(R.layout.select_folder_layout);
        selectFolder(getIntent());
    }
}

From source file:com.nest5.businessClient.Initialactivity.java

/**
 * Begins the activity./* w w w . j  av a 2 s  .c o m*/
 */
@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    this.savedInstanceState = savedInstanceState;
    getWindow().setFormat(PixelFormat.RGBA_8888);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);
    BugSenseHandler.initAndStartSession(Initialactivity.this, "1a5a6af1");
    setContentView(R.layout.swipe_view);
    checkLogin();
    // add necessary intent values to be matched.

    intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
    intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
    intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
    intentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);

    manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
    channel = manager.initialize(this, getMainLooper(), null);
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    dbHelper = new MySQLiteHelper(this);
    ingredientCategoryDatasource = new IngredientCategoryDataSource(dbHelper);
    db = ingredientCategoryDatasource.open();
    ingredientCategories = ingredientCategoryDatasource.getAllIngredientCategory();
    // ingredientCategoryDatasource.close();
    productCategoryDatasource = new ProductCategoryDataSource(dbHelper);
    productCategoryDatasource.open(db);
    productsCategories = productCategoryDatasource.getAllProductCategory();
    taxDataSource = new TaxDataSource(dbHelper);
    taxDataSource.open(db);
    taxes = taxDataSource.getAllTax();
    unitDataSource = new UnitDataSource(dbHelper);
    unitDataSource.open(db);
    units = unitDataSource.getAllUnits();
    ingredientDatasource = new IngredientDataSource(dbHelper);
    ingredientDatasource.open(db);
    ingredientes = ingredientDatasource.getAllIngredient();
    productDatasource = new ProductDataSource(dbHelper);
    productDatasource.open(db);
    productos = productDatasource.getAllProduct();
    comboDatasource = new ComboDataSource(dbHelper);
    comboDatasource.open(db);
    combos = comboDatasource.getAllCombos();
    saleDataSource = new SaleDataSource(dbHelper);
    saleDataSource.open(db);
    saleList = saleDataSource.getAllSales();
    syncRowDataSource = new SyncRowDataSource(dbHelper);
    syncRowDataSource.open(db);

    Calendar today = Calendar.getInstance();
    Calendar tomorrow = Calendar.getInstance();
    today.set(Calendar.HOUR, 0);
    today.set(Calendar.HOUR_OF_DAY, 0);
    today.set(Calendar.MINUTE, 0);
    today.set(Calendar.SECOND, 0);
    today.set(Calendar.MILLISECOND, 0);
    tomorrow.roll(Calendar.DATE, 1);
    tomorrow.set(Calendar.HOUR, 0);
    tomorrow.set(Calendar.HOUR_OF_DAY, 0);
    tomorrow.set(Calendar.MINUTE, 0);
    tomorrow.set(Calendar.SECOND, 0);
    tomorrow.set(Calendar.MILLISECOND, 0);

    init = today.getTimeInMillis();
    end = tomorrow.getTimeInMillis();
    //Log.d(TAG, today.toString());
    //Log.d(TAG, tomorrow.toString());
    Calendar now = Calendar.getInstance();
    now.setTimeInMillis(System.currentTimeMillis());
    //Log.d(TAG, now.toString());

    //Log.d(TAG, "Diferencia entre tiempos: " + String.valueOf(end - init));
    salesFromToday = saleDataSource.getAllSalesWithin(init, end);
    updateRegistrables();
    // ingredientDatasource.close();
    mDemoCollectionPagerAdapter = new DemoCollectionPagerAdapter(getSupportFragmentManager());
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mDemoCollectionPagerAdapter);

    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between pages, select the
            // corresponding tab.
            getActionBar().setSelectedNavigationItem(position);

        }
    });

    final ActionBar actionBar = getActionBar();
    // Specify that tabs should be displayed in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create a tab listener that is called when the user changes tabs.
    ActionBar.TabListener tabListener = new ActionBar.TabListener() {

        @Override
        public void onTabReselected(Tab tab, FragmentTransaction ft) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onTabSelected(Tab tab, FragmentTransaction ft) {
            mViewPager.setCurrentItem(tab.getPosition());

        }

        @Override
        public void onTabUnselected(Tab tab, FragmentTransaction ft) {
            // TODO Auto-generated method stub

        }

    };

    Tab homeTab = actionBar.newTab().setText("Inicio").setTabListener(tabListener);
    Tab ordersTab = actionBar.newTab().setText("rdenes").setTabListener(tabListener);
    /*Tab dailyTab = actionBar.newTab().setText("Registros")
    .setTabListener(tabListener);
    Tab inventoryTab = actionBar.newTab().setText("Inventarios")
    .setTabListener(tabListener);*/
    Tab nest5ReadTab = actionBar.newTab().setText("Nest5").setTabListener(tabListener);
    actionBar.addTab(homeTab, true);
    actionBar.addTab(ordersTab, false);
    //actionBar.addTab(dailyTab, false);
    //actionBar.addTab(inventoryTab, false);
    actionBar.addTab(nest5ReadTab, false);

    currentOrder = new LinkedHashMap<Registrable, Integer>();
    inTableRegistrable = new ArrayList<Registrable>();
    savedOrders = new LinkedHashMap<String, LinkedHashMap<Registrable, Integer>>();
    cookingOrders = new LinkedList<LinkedHashMap<Registrable, Integer>>();
    //cookingOrdersMethods = new LinkedHashMap<LinkedHashMap<Registrable, Integer>, String>();
    cookingOrdersDelivery = new LinkedHashMap<LinkedHashMap<Registrable, Integer>, Integer>();
    cookingOrdersTogo = new LinkedHashMap<LinkedHashMap<Registrable, Integer>, Integer>();
    //cookingOrdersTip = new LinkedHashMap<LinkedHashMap<Registrable, Integer>, Integer>();
    //cookingOrdersDiscount = new LinkedHashMap<LinkedHashMap<Registrable, Integer>, Double>();
    cookingOrdersTimes = new LinkedHashMap<LinkedHashMap<Registrable, Integer>, Long>();
    cookingOrdersTable = new LinkedHashMap<LinkedHashMap<Registrable, Integer>, CurrentTable<Table, Integer>>();
    openTables = new LinkedList<CurrentTable<Table, Integer>>();
    //cookingOrdersReceived = new LinkedHashMap<LinkedHashMap<Registrable, Integer>, Double>();
    frases = getResources().getStringArray(R.array.phrases);
    timer = new Timer();
    deviceID = DeviceID.getDeviceId(mContext);
    //////Log.i("AACCCAAAID",deviceID);
    BebasFont = Typeface.createFromAsset(getAssets(), "fonts/BebasNeue.otf");
    VarelaFont = Typeface.createFromAsset(getAssets(), "fonts/Varela-Regular.otf");
    // Lector de tarjetas magnticas
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    //mReader = new ACR31Reader(mAudioManager);
    /* Initialize the reset progress dialog */

    mResetProgressDialog = new ProgressDialog(mContext);

    // ACR31 RESET CALLBACK
    /*mReader.setOnResetCompleteListener(new ACR31Reader.OnResetCompleteListener() {
            
               
       //hola como estas
       @Override
       public void onResetComplete(ACR31Reader reader) {
            
    if (mSettingSleepTimeout) {
            
            
       mGettingStatus = true;
            
            
       mReader.setSleepTimeout(mSleepTimeout);
       mSettingSleepTimeout = false;
    }
            
    runOnUiThread(new Runnable() {
            
       @Override
       public void run() {
          mResetProgressDialog.dismiss();
       };
    });
       }
    });*/
    /* Set the raw data callback. */
    /*mReader.setOnRawDataAvailableListener(new ACR31Reader.OnRawDataAvailableListener() {
            
       @Override
       public void onRawDataAvailable(ACR31Reader reader, byte[] rawData) {
    ////Log.i("MISPRUEBAS", "setOnRawDataAvailableListener");
            
    final String hexString = toHexString(rawData)
          + (reader.verifyData(rawData) ? " (Checksum OK)"
                : " (Checksum Error)");
            
    ////Log.i("MISPRUEBAS", hexString);
    if (reader.verifyData(rawData)) {
       runOnUiThread(new Runnable() {
            
          @Override
          public void run() {
            
             mResetProgressDialog
                   .setMessage("Solicitando Informacin al Servidor...");
             mResetProgressDialog.setCancelable(false);
             mResetProgressDialog.setIndeterminate(true);
             mResetProgressDialog.show();
            
          }
       });
       SharedPreferences prefs = Util
             .getSharedPreferences(mContext);
            
       restService = new RestService(recievePromoandUserHandler,
             mContext, Setup.PROD_URL
                   + "/company/initMagneticStamp");
       restService.addParam("company",
             prefs.getString(Setup.COMPANY_ID, "0"));
       restService.addParam("magnetic5", hexString);
       restService.setCredentials("apiadmin", Setup.apiKey);
       try {
          restService.execute(RestService.POST);
       } catch (Exception e) {
          e.printStackTrace();
          ////Log.i("MISPRUEBAS", "Error empezando request");
       }
    }
            
       }
    });*/

}

From source file:com.example.search.car.pools.welcome.java

private void showSearchDialog() {
    promptsView = new Dialog(this);
    promptsView.requestWindowFeature(Window.FEATURE_NO_TITLE);
    promptsView.setContentView(R.layout.search);
    promptsView.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    RelativeLayout rl = (RelativeLayout) promptsView.findViewById(R.id.RelativeLayout1);
    rl.setBackgroundColor(Color.parseColor("#00000000"));
    l_1 = (LinearLayout) promptsView.findViewById(R.id.dgdf);
    l_2 = (LinearLayout) promptsView.findViewById(R.id.ddf);
    l_3 = (LinearLayout) promptsView.findViewById(R.id.gdf);
    et_from = (EditText) promptsView.findViewById(R.id.et_search_from);
    et_to = (EditText) promptsView.findViewById(R.id.et_search_to);
    sp_city = (TextView) promptsView.findViewById(R.id.sp_sec_city);
    sp_category = (TextView) promptsView.findViewById(R.id.sp_category);
    sp_search_for = (TextView) promptsView.findViewById(R.id.sp_search_for);
    b_search = (Button) promptsView.findViewById(R.id.b_search);
    close = (RelativeLayout) promptsView.findViewById(R.id.iv_close);
    close.setVisibility(View.VISIBLE);
    close.setOnClickListener(this);
    b_search.setOnClickListener(this);
    sp_city.setOnClickListener(this);
    sp_category.setOnClickListener(this);
    sp_search_for.setOnClickListener(this);
    l_1.setOnClickListener(this);
    l_2.setOnClickListener(this);
    l_3.setOnClickListener(this);
    Typeface tf = Typeface.createFromAsset(welcome.this.getAssets(), "AvenirLTStd_Book.otf");
    et_from.setTypeface(tf);//from  ww w .j  a v  a  2s . c om
    b_search.setTypeface(tf);
    et_to.setTypeface(tf);
    sp_category.setTypeface(tf);
    sp_city.setTypeface(tf);
    sp_search_for.setTypeface(tf);
    promptsView.show();
}