List of usage examples for android.graphics Typeface createFromAsset
public static Typeface createFromAsset(AssetManager mgr, String path)
From source file:com.hughes.android.dictionary.DictionaryActivity.java
@Override public void onCreate(Bundle savedInstanceState) { // This needs to be before super.onCreate, otherwise ActionbarSherlock // doesn't makes the background of the actionbar white when you're // in the dark theme. setTheme(((DictionaryApplication) getApplication()).getSelectedTheme().themeId); Log.d(LOG, "onCreate:" + this); super.onCreate(savedInstanceState); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); // Don't auto-launch if this fails. prefs.edit().remove(C.DICT_FILE).commit(); setContentView(R.layout.dictionary_activity); application = (DictionaryApplication) getApplication(); theme = application.getSelectedTheme(); textColorFg = getResources().getColor(theme.tokenRowFgColor); final Intent intent = getIntent(); String intentAction = intent.getAction(); /**/* ww w . j ava 2s .c om*/ * @author Dominik Kppl Querying the Intent * com.hughes.action.ACTION_SEARCH_DICT is the advanced query * Arguments: SearchManager.QUERY -> the phrase to search from * -> language in which the phrase is written to -> to which * language shall be translated */ if (intentAction != null && intentAction.equals("com.hughes.action.ACTION_SEARCH_DICT")) { String query = intent.getStringExtra(SearchManager.QUERY); String from = intent.getStringExtra("from"); if (from != null) from = from.toLowerCase(Locale.US); String to = intent.getStringExtra("to"); if (to != null) to = to.toLowerCase(Locale.US); if (query != null) { getIntent().putExtra(C.SEARCH_TOKEN, query); } if (intent.getStringExtra(C.DICT_FILE) == null && (from != null || to != null)) { Log.d(LOG, "DictSearch: from: " + from + " to " + to); List<DictionaryInfo> dicts = application.getDictionariesOnDevice(null); for (DictionaryInfo info : dicts) { boolean hasFrom = from == null; boolean hasTo = to == null; for (IndexInfo index : info.indexInfos) { if (!hasFrom && index.shortName.toLowerCase(Locale.US).equals(from)) hasFrom = true; if (!hasTo && index.shortName.toLowerCase(Locale.US).equals(to)) hasTo = true; } if (hasFrom && hasTo) { if (from != null) { int which_index = 0; for (; which_index < info.indexInfos.size(); ++which_index) { if (info.indexInfos.get(which_index).shortName.toLowerCase(Locale.US).equals(from)) break; } intent.putExtra(C.INDEX_SHORT_NAME, info.indexInfos.get(which_index).shortName); } intent.putExtra(C.DICT_FILE, application.getPath(info.uncompressedFilename).toString()); break; } } } } /** * @author Dominik Kppl Querying the Intent Intent.ACTION_SEARCH is a * simple query Arguments follow from android standard (see * documentation) */ if (intentAction != null && intentAction.equals(Intent.ACTION_SEARCH)) { String query = intent.getStringExtra(SearchManager.QUERY); if (query != null) getIntent().putExtra(C.SEARCH_TOKEN, query); } /** * @author Dominik Kppl If no dictionary is chosen, use the default * dictionary specified in the preferences If this step does * fail (no default directory specified), show a toast and * abort. */ if (intent.getStringExtra(C.DICT_FILE) == null) { String dictfile = prefs.getString(getString(R.string.defaultDicKey), null); if (dictfile != null) intent.putExtra(C.DICT_FILE, application.getPath(dictfile).toString()); } String dictFilename = intent.getStringExtra(C.DICT_FILE); if (dictFilename == null) { Toast.makeText(this, getString(R.string.no_dict_file), Toast.LENGTH_LONG).show(); startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext())); finish(); return; } if (dictFilename != null) dictFile = new File(dictFilename); ttsReady = false; textToSpeech = new TextToSpeech(getApplicationContext(), new OnInitListener() { @Override public void onInit(int status) { ttsReady = true; updateTTSLanguage(indexIndex); } }); try { final String name = application.getDictionaryName(dictFile.getName()); this.setTitle("QuickDic: " + name); dictRaf = new RandomAccessFile(dictFile, "r"); dictionary = new Dictionary(dictRaf); } catch (Exception e) { Log.e(LOG, "Unable to load dictionary.", e); if (dictRaf != null) { try { dictRaf.close(); } catch (IOException e1) { Log.e(LOG, "Unable to close dictRaf.", e1); } dictRaf = null; } Toast.makeText(this, getString(R.string.invalidDictionary, "", e.getMessage()), Toast.LENGTH_LONG) .show(); startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext())); finish(); return; } String targetIndex = intent.getStringExtra(C.INDEX_SHORT_NAME); if (savedInstanceState != null && savedInstanceState.getString(C.INDEX_SHORT_NAME) != null) { targetIndex = savedInstanceState.getString(C.INDEX_SHORT_NAME); } indexIndex = 0; for (int i = 0; i < dictionary.indices.size(); ++i) { if (dictionary.indices.get(i).shortName.equals(targetIndex)) { indexIndex = i; break; } } Log.d(LOG, "Loading index " + indexIndex); index = dictionary.indices.get(indexIndex); setListAdapter(new IndexAdapter(index)); // Pre-load the collators. new Thread(new Runnable() { public void run() { android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND); final long startMillis = System.currentTimeMillis(); try { TransliteratorManager.init(new TransliteratorManager.Callback() { @Override public void onTransliteratorReady() { uiHandler.post(new Runnable() { @Override public void run() { onSearchTextChange(searchView.getQuery().toString()); } }); } }); for (final Index index : dictionary.indices) { final String searchToken = index.sortedIndexEntries.get(0).token; final IndexEntry entry = index.findExact(searchToken); if (entry == null || !searchToken.equals(entry.token)) { Log.e(LOG, "Couldn't find token: " + searchToken + ", " + (entry == null ? "null" : entry.token)); } } indexPrepFinished = true; } catch (Exception e) { Log.w(LOG, "Exception while prepping. This can happen if dictionary is closed while search is happening."); } Log.d(LOG, "Prepping indices took:" + (System.currentTimeMillis() - startMillis)); } }).start(); String fontName = prefs.getString(getString(R.string.fontKey), "FreeSerif.otf.jpg"); if ("SYSTEM".equals(fontName)) { typeface = Typeface.DEFAULT; } else if ("SERIF".equals(fontName)) { typeface = Typeface.SERIF; } else if ("SANS_SERIF".equals(fontName)) { typeface = Typeface.SANS_SERIF; } else if ("MONOSPACE".equals(fontName)) { typeface = Typeface.MONOSPACE; } else { if ("FreeSerif.ttf.jpg".equals(fontName)) { fontName = "FreeSerif.otf.jpg"; } try { typeface = Typeface.createFromAsset(getAssets(), fontName); } catch (Exception e) { Log.w(LOG, "Exception trying to use typeface, using default.", e); Toast.makeText(this, getString(R.string.fontFailure, e.getLocalizedMessage()), Toast.LENGTH_LONG) .show(); } } if (typeface == null) { Log.w(LOG, "Unable to create typeface, using default."); typeface = Typeface.DEFAULT; } final String fontSize = prefs.getString(getString(R.string.fontSizeKey), "14"); try { fontSizeSp = Integer.parseInt(fontSize.trim()); } catch (NumberFormatException e) { fontSizeSp = 14; } // ContextMenu. registerForContextMenu(getListView()); // Cache some prefs. wordList = application.getWordListFile(); saveOnlyFirstSubentry = prefs.getBoolean(getString(R.string.saveOnlyFirstSubentryKey), false); clickOpensContextMenu = prefs.getBoolean(getString(R.string.clickOpensContextMenuKey), false); Log.d(LOG, "wordList=" + wordList + ", saveOnlyFirstSubentry=" + saveOnlyFirstSubentry); onCreateSetupActionBarAndSearchView(); // Set the search text from the intent, then the saved state. String text = getIntent().getStringExtra(C.SEARCH_TOKEN); if (savedInstanceState != null) { text = savedInstanceState.getString(C.SEARCH_TOKEN); } if (text == null) { text = ""; } setSearchText(text, true); Log.d(LOG, "Trying to restore searchText=" + text); setDictionaryPrefs(this, dictFile, index.shortName, searchView.getQuery().toString()); updateLangButton(); searchView.requestFocus(); // http://stackoverflow.com/questions/2833057/background-listview-becomes-black-when-scrolling // getListView().setCacheColorHint(0); }
From source file:gov.wa.wsdot.android.wsdot.ui.tollrates.I405TollRatesFragment.java
/** * Returns a view for the toll trip provided by the tripItem. * A tripItem holds information about the trip destination and toll rate * * @param tripItem/*w w w . jav a 2 s .c o m*/ * @param context * @return */ public static View makeTripView(TollTripEntity tripItem, TollRateSignEntity sign, Context context) { Typeface tfb = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Bold.ttf"); LayoutInflater li = LayoutInflater.from(context); View cv = li.inflate(R.layout.trip_view, null); // set end location label ((TextView) cv.findViewById(R.id.title)).setText("to ".concat(tripItem.getEndLocationName())); ((TextView) cv.findViewById(R.id.subtitle)).setText("Show on map"); ((TextView) cv.findViewById(R.id.subtitle)) .setTextColor(context.getResources().getColor(R.color.primary_default)); cv.findViewById(R.id.subtitle).setOnClickListener(v -> { Bundle b = new Bundle(); b.putDouble("startLat", sign.getStartLatitude()); b.putDouble("startLong", sign.getStartLongitude()); b.putDouble("endLat", tripItem.getEndLatitude()); b.putDouble("endLong", tripItem.getEndLongitude()); b.putString("title", sign.getLocationName()); b.putString("text", String.format("Travel as far as %s.", tripItem.getEndLocationName())); Intent intent = new Intent(context, TollRatesRouteActivity.class); intent.putExtras(b); context.startActivity(intent); }); cv.findViewById(R.id.content).setVisibility(View.GONE); // set updated label ((TextView) cv.findViewById(R.id.updated)) .setText(ParserUtils.relativeTime(tripItem.getUpdated(), "MMMM d, yyyy h:mm a", false)); // set toll TextView currentTimeTextView = cv.findViewById(R.id.current_value); currentTimeTextView.setTypeface(tfb); currentTimeTextView.setText(String.format(Locale.US, "$%.2f", tripItem.getTollRate() / 100)); // set message if there is one if (!tripItem.getMessage().equals("null")) { currentTimeTextView.setText(tripItem.getMessage()); } return cv; }
From source file:com.corporatetaxi.TaxiArrived_Acitivity.java
private void initiatePopupWindowcanceltaxi() { try {// ww w . j a va2 s . co m dialog = new Dialog(TaxiArrived_Acitivity.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_confirm = (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_confirm.setTypeface(tf); txt.setTypeface(tf); textheader.setTypeface(tf); btn_confirm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (rd1.isChecked()) { canceltaxirequest = getResources().getString(R.string.prompt_cancel_reason_one); } 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.baseutil.strip.PagerSlidingTabStrip.java
public void setTypefaceCustom(int assestFileName, int style) { tabTypeface = Typeface.createFromAsset(getContext().getAssets(), getContext().getString(assestFileName)); this.tabTypefaceStyle = style; updateTabStyles();//from ww w. j av a 2 s. co m }
From source file:com.seatgeek.placesautocompletedemo.MainFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_main, container, false); mapActivity = getActivity();/*from w w w .ja v a2 s . c o m*/ dataProvider = new DataProvider(mapActivity); placePickerGoogle(placePickerIntent); tinydb = new TinyDB(getContext()); arrayListBookmark = tinydb.getListString("BOOKMARK"); recyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_cmt); scrollView = (NestedScrollView) rootView.findViewById(R.id.scrollView); mAdapter = new MessagesAdapter(getContext(), messages, this); RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getContext()); recyclerView.setLayoutManager(mLayoutManager); recyclerView.setItemAnimator(new DefaultItemAnimator()); recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), LinearLayoutManager.VERTICAL)); recyclerView.setAdapter(mAdapter); recyclerView.setNestedScrollingEnabled(false); recyclerView.setFocusable(false); scrollView.scrollTo(0, 0); // mListView = (LockableRecyclerView) rootView.findViewById(android.R.id.list); // mListView.setOverScrollMode(ListView.OVER_SCROLL_NEVER); searchLocation = (CardView) rootView.findViewById(R.id.search_bar); searchLocation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN); startActivityForResult(placePickerIntent, PLACE_AUTOCOMPLETE_REQUEST_CODE); } }); final LayoutInflater inflatera = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); customView = inflatera.inflate(R.layout.review, null); dialogReview = new MaterialStyledDialog.Builder(getActivity()).setHeaderDrawable(R.drawable.header_2) .setCustomView(customView, 20, 20, 20, 0).build(); btn_Rate = (Button) rootView.findViewById(R.id.btn_rate); btn_book = (Button) rootView.findViewById(R.id.btn_book); btn_Rate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // if (customView != null) { // ViewGroup parent = (ViewGroup) customView.getParent(); // if (parent != null) { // parent.removeView(customView); // } // } // try { // customView = inflatera.inflate(R.layout.review,null); // } catch (InflateException e) { // // } // dialogHeader_4.getBuilder().setCustomView(customView,20,20,20,0); dialogReview.show(); } }); btn_book.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (arrayListBookmark.contains(currentPos)) { btn_book.setBackgroundResource(R.drawable.star_off); arrayListBookmark.remove(currentPos); } else { btn_book.setBackgroundResource(R.drawable.star_on); arrayListBookmark.add(currentPos); } tinydb.putListString("BOOKMARK", arrayListBookmark); // btn_book.setBackgroundResource(R.drawable.star_on); } }); rating = (SmileRating) customView.findViewById(R.id.ratingsBar); final EditText ed_review = (EditText) customView.findViewById(R.id.reviewED); final EditText ed_title = (EditText) customView.findViewById(R.id.titleED); Button cancelDialog = (Button) customView.findViewById(R.id.cancelD); cancelDialog.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialogReview.dismiss(); } }); Button submitDialog = (Button) customView.findViewById(R.id.submitD); submitDialog.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Toast.makeText(getActivity().getApplicationContext(),""+rating.getRating(),Toast.LENGTH_SHORT).show(); sendComment(10, ed_review.getText().toString().trim(), ed_title.getText().toString().trim(), rating.getRating(), new ParkingCar()); } }); sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mapActivity); latitude = sharedPreferences.getString("LATITUDE", null); longitude = sharedPreferences.getString("LONGITUDE", null); RADIUS = sharedPreferences.getString("RADIUS", "1000"); ViewPager pager = (ViewPager) rootView.findViewById(R.id.pager); pager.setAdapter(new ImageAdapter(getActivity())); pager.setCurrentItem(getArguments().getInt(Constants.Extra.IMAGE_POSITION, 0)); pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { for (int i = 0; i < dotsCount; i++) { dots[i].setTextColor(getResources().getColor(android.R.color.black)); } dots[position].setTextColor(Color.GREEN); } @Override public void onPageSelected(int position) { } @Override public void onPageScrollStateChanged(int state) { } }); setUiPageViewController(rootView); mLayout = (SlidingUpPanelLayout) rootView.findViewById(R.id.sliding_layout); mLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); mLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN); mLayout.setAnchorPoint(0.68f); mLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() { @Override public void onPanelSlide(View panel, float slideOffset) { Log.i("", "onPanelSlide, offset " + slideOffset); } @Override public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) { Log.i("", "onPanelStateChanged " + newState); if (newState == SlidingUpPanelLayout.PanelState.COLLAPSED) { scrollView.scrollTo(0, 0); } } }); mLayout.setFadeOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); } }); txt_Adress = (TextView) rootView.findViewById(R.id.name); txt_Scale = (TextView) rootView.findViewById(R.id.txt_Scale); txt_Add = (TextView) rootView.findViewById(R.id.textView3); txt_Type = (TextView) rootView.findViewById(R.id.textView4); txt_Rate = (TextView) rootView.findViewById(R.id.textView5); Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "font/UTM Avo.ttf"); Typeface tf1 = Typeface.createFromAsset(getActivity().getAssets(), "font/UTM Dax.ttf"); txt_Adress.setTypeface(tf, Typeface.BOLD); txt_Scale.setTypeface(tf1, Typeface.BOLD); txt_Add.setTypeface(tf1, Typeface.BOLD); txt_Type.setTypeface(tf1, Typeface.BOLD); txt_Rate.setTypeface(tf1, Typeface.BOLD); collapseMap(); return rootView; }
From source file:foam.zizim.android.BoskoiService.java
private Typeface loadFont(String path) { return Typeface.createFromAsset(getAssets(), path); }
From source file:com.affectiva.affdexme.MainActivity.java
void initializeUI() { //Get handles to UI objects ViewGroup activityLayout = (ViewGroup) findViewById(android.R.id.content); progressBarLayout = (RelativeLayout) findViewById(R.id.progress_bar_cover); permissionsUnavailableLayout = (LinearLayout) findViewById(R.id.permissionsUnavialableLayout); metricViewLayout = (RelativeLayout) findViewById(R.id.metric_view_group); leftMetricsLayout = (LinearLayout) findViewById(R.id.left_metrics); rightMetricsLayout = (LinearLayout) findViewById(R.id.right_metrics); mainLayout = (RelativeLayout) findViewById(R.id.main_layout); fpsPct = (TextView) findViewById(R.id.fps_value); fpsName = (TextView) findViewById(R.id.fps_name); cameraView = (SurfaceView) findViewById(R.id.camera_preview); drawingView = (DrawingView) findViewById(R.id.drawing_view); settingsButton = (ImageButton) findViewById(R.id.settings_button); cameraButton = (ImageButton) findViewById(R.id.camera_button); screenshotButton = (ImageButton) findViewById(R.id.screenshot_button); progressBar = (ProgressBar) findViewById(R.id.progress_bar); pleaseWaitTextView = (TextView) findViewById(R.id.please_wait_textview); Button retryPermissionsButton = (Button) findViewById(R.id.retryPermissionsButton); //Initialize views to display metrics metricNames = new TextView[NUM_METRICS_DISPLAYED]; metricNames[0] = (TextView) findViewById(R.id.metric_name_0); metricNames[1] = (TextView) findViewById(R.id.metric_name_1); metricNames[2] = (TextView) findViewById(R.id.metric_name_2); metricNames[3] = (TextView) findViewById(R.id.metric_name_3); metricNames[4] = (TextView) findViewById(R.id.metric_name_4); metricNames[5] = (TextView) findViewById(R.id.metric_name_5); metricDisplays = new MetricDisplay[NUM_METRICS_DISPLAYED]; metricDisplays[0] = (MetricDisplay) findViewById(R.id.metric_pct_0); metricDisplays[1] = (MetricDisplay) findViewById(R.id.metric_pct_1); metricDisplays[2] = (MetricDisplay) findViewById(R.id.metric_pct_2); metricDisplays[3] = (MetricDisplay) findViewById(R.id.metric_pct_3); metricDisplays[4] = (MetricDisplay) findViewById(R.id.metric_pct_4); metricDisplays[5] = (MetricDisplay) findViewById(R.id.metric_pct_5); //Load Application Font and set UI Elements to use it Typeface face = Typeface.createFromAsset(getAssets(), "fonts/Square.ttf"); for (TextView textView : metricNames) { textView.setTypeface(face);//from w w w . ja v a 2 s . c om } for (MetricDisplay metricDisplay : metricDisplays) { metricDisplay.setTypeface(face); } fpsPct.setTypeface(face); fpsName.setTypeface(face); drawingView.setTypeface(face); pleaseWaitTextView.setTypeface(face); //Hide left and right metrics by default (will be made visible when face detection starts) leftMetricsLayout.setAlpha(0); rightMetricsLayout.setAlpha(0); /** * This app uses two SurfaceView objects: one to display the camera image and the other to draw facial tracking dots. * Since we want the tracking dots to appear over the camera image, we use SurfaceView.setZOrderMediaOverlay() to indicate that * cameraView represents our 'media', and drawingView represents our 'overlay', so that Android will render them in the * correct order. */ drawingView.setZOrderMediaOverlay(true); cameraView.setZOrderMediaOverlay(false); //Attach event listeners to the menu and edit box activityLayout.setOnTouchListener(this); //Attach event listerner to drawing view drawingView.setEventListener(this); /* * This app sets the View.SYSTEM_UI_FLAG_HIDE_NAVIGATION flag. Unfortunately, this flag causes * Android to steal the first touch event after the navigation bar has been hidden, a touch event * which should be used to make our menu visible again. Therefore, we attach a listener to be notified * when the navigation bar has been made visible again, which corresponds to the touch event that Android * steals. If the menu bar was not visible, we make it visible. */ activityLayout.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int uiCode) { if ((uiCode == 0) && (!isMenuVisible)) { setMenuVisible(true); } } }); retryPermissionsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { requestCameraPermissions(); } }); }
From source file:com.brandao.tictactoe.board.BoardFragment.java
public void showGameOverDialog() { Typeface titleFont = Typeface.createFromAsset(getActivity().getAssets(), "fonts/DroidSans-Bold.ttf"); final View gameOverLayout = LayoutInflater.from(getActivity()).inflate(R.layout.game_over_dialog, null); ((TextView) gameOverLayout.findViewById(R.id.player_one_name_display)).setText(mPlayerOneName); ((TextView) gameOverLayout.findViewById(R.id.player_one_name_display)).setTypeface(titleFont); ((TextView) gameOverLayout.findViewById(R.id.player_two_name_display)).setText(mPlayerTwoName); ((TextView) gameOverLayout.findViewById(R.id.player_two_name_display)).setTypeface(titleFont); ((TextView) gameOverLayout.findViewById(R.id.player_tie_name_display)).setText(getString(R.string.ties)); ((TextView) gameOverLayout.findViewById(R.id.player_tie_name_display)).setTypeface(titleFont); ((TextView) gameOverLayout.findViewById(R.id.winner_name_display)).setTypeface(titleFont); if (mLastGameWinner == C.SYMBLE_PLAYER_ONE) { String oneWins = mPlayerOneName + " " + getString(R.string.wins) + "!"; ((TextView) gameOverLayout.findViewById(R.id.winner_name_display)).setText(oneWins); ((ImageView) gameOverLayout.findViewById(R.id.winner_image_display)) .setBackgroundResource(R.drawable.ic_green_x_android); } else {// w w w . j a va2 s. c om if (mLastGameWinner == C.SYMBLE_PLAYER_TWO) { String twoWins = mPlayerTwoName + " " + getString(R.string.wins) + "!"; ((TextView) gameOverLayout.findViewById(R.id.winner_name_display)).setText(twoWins); ((ImageView) gameOverLayout.findViewById(R.id.winner_image_display)) .setBackgroundResource(R.drawable.ic_red_o_android); } else { ((TextView) gameOverLayout.findViewById(R.id.winner_name_display)) .setText(getString(R.string.its_a_tie)); ((ImageView) gameOverLayout.findViewById(R.id.winner_image_display)) .setBackgroundResource(R.drawable.ic_grey_android); } } ((ImageView) gameOverLayout.findViewById(R.id.player_one_image)) .setBackgroundResource(R.drawable.ic_green_x_android); ((ImageView) gameOverLayout.findViewById(R.id.player_two_image)) .setBackgroundResource(R.drawable.ic_red_o_android); ((ImageView) gameOverLayout.findViewById(R.id.player_tie_image)) .setBackgroundResource(R.drawable.ic_grey_android); ((TextView) gameOverLayout.findViewById(R.id.player_one_score)).setText(": " + mPlayerOneWins); ((TextView) gameOverLayout.findViewById(R.id.player_one_score)).setTypeface(titleFont); ((TextView) gameOverLayout.findViewById(R.id.player_two_score)).setText(": " + mPlayerTwoWins); ((TextView) gameOverLayout.findViewById(R.id.player_two_score)).setTypeface(titleFont); ((TextView) gameOverLayout.findViewById(R.id.player_tie_score)).setText(": " + mTotalTies); ((TextView) gameOverLayout.findViewById(R.id.player_tie_score)).setTypeface(titleFont); ((TextView) gameOverLayout.findViewById(R.id.winner_time_display)).setTypeface(titleFont); ((TextView) gameOverLayout.findViewById(R.id.winner_time_display)).setText(mGameTime + " ms"); new Builder(getActivity()).setView(gameOverLayout) .setNegativeButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { } }).setPositiveButton(R.string.restart, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { restartGame(mPrefs.getBoolean(Settings.PREF_ANIMATE, true)); } }).create().show(); }
From source file:devlight.io.library.ArcProgressStackView.java
public void setTypeface(final String typeface) { Typeface tempTypeface;//from w ww. j av a2 s . c om try { if (isInEditMode()) return; tempTypeface = Typeface.createFromAsset(getContext().getAssets(), typeface); } catch (Exception e) { tempTypeface = Typeface.create(Typeface.DEFAULT, Typeface.NORMAL); } setTypeface(tempTypeface); }
From source file:net.emilymaier.movebot.MoveBotActivity.java
@Override @SuppressWarnings({ "deprecation", "unchecked" }) public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);/*from w ww . j a v a 2 s .c o m*/ PreferenceManager.setDefaultValues(this, R.xml.preferences, false); Units.initialize(this); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); runs = new ArrayList<>(); try { FileInputStream fis = openFileInput("runs.ser"); ObjectInputStream ois = new ObjectInputStream(fis); runs = (ArrayList<Run>) ois.readObject(); ois.close(); fis.close(); } catch (FileNotFoundException e) { } catch (IOException e) { throw new RuntimeException("IOException", e); } catch (ClassNotFoundException e) { throw new RuntimeException("ClassNotFoundException", e); } font = Typeface.createFromAsset(getAssets(), "fonts/led_real.ttf"); pager = (ViewPager) findViewById(R.id.pager); adapter = new MainPagerAdapter(getSupportFragmentManager()); runsFragment = new RunsFragment(); heartFragment = new HeartFragment(this); developerFragment = new DeveloperFragment(); controlFragment = new ControlFragment(); mapFragment = SupportMapFragment.newInstance(); pager.setAdapter(adapter); updateDeveloperMode(); gpsInfoTimer = new Timer(); gpsInfoTimer.schedule(new GpsInfoTask(), 2 * 1000); mapFragment.getMapAsync(this); BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (bluetoothAdapter != null) { if (!bluetoothAdapter.isEnabled()) { Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(intent, 1); } } }