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:org.crossconnect.bible.activity.main.BibleTextFragment.java

private void loadSettings() {
    SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    // Now, we're going to check for the Text size variable and set the text
    // size/*from  w w w .  j a va2 s  .c  o m*/

    bibleTextView.setTextSize(
            Float.parseFloat(appPreferences.getString(getActivity().getString(R.string.text_size_key), "18")));

    int color = appPreferences.getInt(getActivity().getString(R.string.text_color_key), Color.BLACK);
    bibleTextView.setTextColor(color);

    try {
        //Set Custom font
        bibleTextView
                .setTypeface(
                        Typeface.createFromAsset(getActivity().getAssets(),
                                "fonts/" + appPreferences.getString(
                                        getActivity().getString(R.string.text_font_key), "Ubuntu-R.ttf")),
                        Typeface.NORMAL);
        //            this.setTypeface(Typeface.createFromAsset(ctx.getAssets(), "fonts/" + "Ubuntu-B.ttf"), Typeface.BOLD);
    } catch (Exception e) {
        //Custom font not found
        Log.d(TAG, "Font not found!", e);
    }

}

From source file:com.spacescout.spacescout_android.MainActivity.java

@Override
public void onResume() {
    super.onResume();
    LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflator.inflate(R.layout.custom_title_actionbar, null);

    Typeface typeface = Typeface.createFromAsset(this.getAssets(), "fonts/Manteka.ttf");

    TextView titleSpace = (TextView) v.findViewById(R.id.titleSpace);
    TextView titleScout = (TextView) v.findViewById(R.id.titleScout);
    titleSpace.setTypeface(typeface);/*from  ww w  . j  ava2s  . c o m*/
    titleScout.setTypeface(typeface);

    getActionBar().setCustomView(v);
}

From source file:com.dm.material.dashboard.candybar.activities.CandyBarWallpaperActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == android.R.id.home) {
        onBackPressed();//from   ww  w .j  av  a  2 s  .c o  m
        return true;
    } else if (id == R.id.menu_save) {
        if (PermissionHelper.isPermissionStorageGranted(this)) {
            File target = new File(WallpaperHelper.getDefaultWallpapersDirectory(this).toString()
                    + File.separator + mName + FileHelper.IMAGE_EXTENSION);

            if (target.exists()) {
                CafeBar.builder(this)
                        .theme(new CafeBarTheme.Custom(
                                ColorHelper.getAttributeColor(this, R.attr.card_background)))
                        .autoDismiss(false).maxLines(4).fitSystemWindow(true)
                        .content(String.format(getResources().getString(R.string.wallpaper_download_exist),
                                ("\"" + mName + FileHelper.IMAGE_EXTENSION + "\"")))
                        .icon(R.drawable.ic_toolbar_download)
                        .positiveText(R.string.wallpaper_download_exist_replace).positiveColor(mColor)
                        .positiveTypeface(Typeface.createFromAsset(getAssets(), "fonts/Font-Bold.ttf"))
                        .onPositive(cafeBar -> {
                            WallpaperHelper.downloadWallpaper(this, mColor, mUrl, mName);
                            cafeBar.dismiss();
                        }).negativeText(R.string.wallpaper_download_exist_new)
                        .negativeTypeface(Typeface.createFromAsset(getAssets(), "fonts/Font-Bold.ttf"))
                        .onNegative(cafeBar -> {
                            WallpaperHelper.downloadWallpaper(this, mColor, mUrl,
                                    mName + "_" + System.currentTimeMillis());
                            cafeBar.dismiss();
                        }).build().show();
                return true;
            }

            WallpaperHelper.downloadWallpaper(this, mColor, mUrl, mName);
            return true;
        }

        PermissionHelper.requestStoragePermission(this);
        return true;
    } else if (id == R.id.menu_wallpaper_settings) {
        WallpaperSettingsFragment.showWallpaperSettings(getSupportFragmentManager());
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.stikyhive.stikyhive.ChattingActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    getWindow().setBackgroundDrawableResource(R.drawable.chat_bg);
    // this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    recipientStkid = getIntent().getExtras().getString("recipientStkid");
    chatRecipient = getIntent().getExtras().getString("chatRecipient");
    chatRecipientUrl = getIntent().getExtras().getString("chatRecipientUrl");
    senderToken = getIntent().getExtras().getString("senderToken");
    recipientToken = getIntent().getExtras().getString("recipientToken");
    noti = getIntent().getExtras().getBoolean("noti");
    message = getIntent().getExtras().getString("message");
    rows = getIntent().getExtras().getInt("rows");
    flagChatting = true;//w  ww  . j  a v a2s . c  o m
    pref = PreferenceManager.getDefaultSharedPreferences(this);
    offerId = 0;
    offerStatus = 0;
    ws = new JsonWebService();
    dbHelper = new DBHelper(this);
    dialog = new ProgressDialog(this);
    listChatContact = new ArrayList<>();
    listChatContact = dbHelper.getChatContact();
    Log.i(" Chat Contact ", " " + listChatContact.size());
    metrics = this.getResources().getDisplayMetrics();
    //to change font
    faceSemi_bold = Typeface.createFromAsset(getAssets(), fontOSSemi_bold);
    Typeface faceLight = Typeface.createFromAsset(getAssets(), fontOSLight);
    faceRegular = Typeface.createFromAsset(getAssets(), fontOSRegular);

    imageLoader = ImageLoader.getInstance();
    if (!imageLoader.isInited()) {
        imageLoader.init(ImageLoaderConfiguration.createDefault(this));
    }

    start = new Date();
    SimpleDateFormat oFormat = new SimpleDateFormat("dd MMM HH:mm");
    timeSend = oFormat.format(start);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.chat);

    layoutTalk = (LinearLayout) findViewById(R.id.layoutTalk);
    txtUserName = (TextView) findViewById(R.id.txtChatName);
    edTxtMsg = (EditText) findViewById(R.id.edTxtMsg);
    imgViewProfile = (ImageView) findViewById(R.id.imgViewChat);
    imgViewAddCon = (ImageView) findViewById(R.id.imgAddContact);
    lv = (ListView) findViewById(R.id.listView1);
    layoutLabel = (LinearLayout) findViewById(R.id.layoutLabel);
    txtLabel1 = (TextView) findViewById(R.id.txtLabel1);
    txtLabel2 = (TextView) findViewById(R.id.txtLabel2);
    txtLabel3 = (TextView) findViewById(R.id.txtLabel3);
    txtLabel2.setText(" " + chatRecipient + " ");
    txtLabel1.setTypeface(faceLight);
    txtLabel2.setTypeface(faceRegular);
    txtLabel3.setTypeface(faceLight);

    for (ChatContact contact : listChatContact) {
        if (contact.getContactId().equals(recipientStkid)) {
            imgViewAddCon.setVisibility(View.INVISIBLE);
            layoutLabel.setVisibility(View.GONE);
            break;
        }
    }
    Log.i(TAG, " come back again");
    adapter = new ChatArrayAdapter(this, R.layout.chatting_listview, faceSemi_bold, faceRegular, recipientStkid,
            senderToken, recipientToken);
    lv.setAdapter(adapter);
    // adapter.add(new StikyChat(chatRecipientUrl, "Hello", false, "12.10.2015", "12.1.2014"));

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
    // BEGIN_INCLUDE (change_colors)
    // Set the color scheme of the SwipeRefreshLayout by providing 4 color resource ids
    swipeRefreshLayout.setColorScheme(R.color.swipe_color_1, R.color.swipe_color_2, R.color.swipe_color_3,
            R.color.swipe_color_4);
    limitMsg = 7;
    // END_INCLUDE (change_colors)
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            Log.i(" Refresh Layout ", "onRefresh called from SwipeRefreshLayout");
            if (limitMsg < rows) {
                Log.i("Limit Message ", " " + limitMsg);
                limitMsg *= 2;
                fetchRecords();
            } else if ((!(rows <= 7)) && limitMsg > rows && (limitMsg - rows < 7)) {
                fetchRecords();
            } else {
                Log.i("No data ", "to refresh");
                swipeRefreshLayout.setRefreshing(false);
                Toast.makeText(getApplicationContext(), "No data to refresh!", Toast.LENGTH_SHORT).show();
            }
            // initiateRefresh();
        }
    });

    LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout headerLayout = (LinearLayout) findViewById(R.id.header);
    View header = inflator.inflate(R.layout.header, null);

    TextView textView = (TextView) header.findViewById(R.id.textView1);
    textView.setText("StikyChat");
    textView.setTypeface(faceSemi_bold);
    textView.setVisibility(View.VISIBLE);
    headerLayout.addView(header);
    LinearLayout layoutRight = (LinearLayout) header.findViewById(R.id.layoutRight);
    layoutRight.setVisibility(View.GONE);

    txtUserName.setText(chatRecipient);
    Log.i(TAG, "Activity Name " + txtUserName.getText().toString());
    txtUserName.setTypeface(faceSemi_bold);

    String url = "";

    Log.i(TAG, " ^^^ " + chatRecipientUrl + " ");
    if (chatRecipientUrl != null) {
        if (chatRecipientUrl.contains("http")) {
            url = chatRecipientUrl;
        } else if (chatRecipientUrl != "null") {
            url = this.getResources().getString(R.string.url) + "/" + chatRecipientUrl;
        }
    }
    addAndroidUniversalImageLoader(imgViewProfile, url);
    //        if (noti && (!message.equals(""))) {
    //            adapter.add(new StikyChat(chatRecipientUrl, message, true, timeSend, ""));
    //            lv.smoothScrollToPosition(adapter.getCount() - 1);
    //        }

    //to show history chats between two users(sender & recipient)
    dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    dateFormat2 = new SimpleDateFormat("dd MMM HH:mm");
    listHistory = dbHelper.getStikyChat();
    if (listHistory.size() > 0) {
        Collections.reverse(listHistory);
        for (final StikyChatTb chatTb : listHistory) {
            String getDate = chatTb.getSendDate();
            String durationStr = null;
            String fromStikyBee = chatTb.getSender();
            try {
                final String createDate = dateFormat2.format(dateFormat.parse(getDate));
                if (chatTb.getFileName().contains("voice")) {
                    MediaPlayer mPlayer = new MediaPlayer();
                    String voiceFileName = getResources().getString(R.string.url) + "/" + chatTb.getFileName();
                    try {
                        mPlayer.setDataSource(voiceFileName);
                        mPlayer.prepare();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }

                    //mPlayer.start();
                    int duration = mPlayer.getDuration();
                    mPlayer.release();
                    duration = (int) Math.ceil(duration / 1024);

                    if (duration < 10) {
                        durationStr = "00:0" + duration;
                    } else {
                        durationStr = "00:" + duration;
                    }
                    // Log.i(TAG, "Duration Srt " + durationStr);
                }
                if (fromStikyBee.equals(pref.getString("stkid", ""))) {
                    //String url1 = getResources().getString(R.string.url) + "/" + chatTb.getFileName();
                    // Log.i(TAG, " Offer Id " + chatTb.getOfferId() + " Price " + chatTb.getPrice() + " Name " + chatTb.getName());
                    //first false = right, second false = Offer
                    //  Log.i(TAG, " Duration " + chatTb.getRate() + " File Name " + chatTb.getFileName());
                    if (!chatTb.getFileName().contains("voice")) {
                        Log.i(TAG, " Voice is not ");
                        adapter.add(new StikyChat(chatRecipientUrl, chatTb.getMessage(), false, createDate,
                                chatTb.getFileName(), chatTb.getOfferId(), chatTb.getOfferStatus(),
                                chatTb.getPrice(), chatTb.getRate(), chatTb.getName(), null,
                                chatTb.getOriFName()));
                    } else {
                        Log.i(TAG, " Voice is ");
                        adapter.add(new StikyChat(chatRecipientUrl, chatTb.getMessage(), false, createDate,
                                chatTb.getFileName(), chatTb.getOfferId(), chatTb.getOfferStatus(),
                                chatTb.getPrice(), chatTb.getRate(), durationStr, null, chatTb.getOriFName()));
                    }
                } else {
                    /* Bitmap bmImg = BitmapFactory.decodeFile(getResources().getString(R.string.url) + "/" + chatTb.getFileName());
                     Bitmap resBm = getResizedBitmap(bmImg, 500);*/
                    // String url1 = getResources().getString(R.string.url) + "/" + chatTb.getFileName();
                    if (!chatTb.getFileName().contains("voice")) {
                        adapter.add(new StikyChat(chatRecipientUrl, chatTb.getMessage(), true, createDate,
                                chatTb.getFileName(), chatTb.getOfferId(), chatTb.getOfferStatus(),
                                chatTb.getPrice(), chatTb.getRate(), chatTb.getName(), null,
                                chatTb.getOriFName()));
                    } else {
                        adapter.add(new StikyChat(chatRecipientUrl, chatTb.getMessage(), true, createDate,
                                chatTb.getFileName(), chatTb.getOfferId(), chatTb.getOfferStatus(),
                                chatTb.getPrice(), chatTb.getRate(), durationStr, null, chatTb.getOriFName()));
                    }
                }
                lv.smoothScrollToPosition(adapter.getCount() - 1);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
    }

    mRegistrationBroadcastReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
            fileNameGCM = sharedPreferences.getString("fileName", "");
            messageGCM = sharedPreferences.getString("message", "");
            offerIdGCM = sharedPreferences.getInt("offerId", 0);
            offerStatusGCM = sharedPreferences.getInt("offerStatus", 0);
            priceGCM = sharedPreferences.getString("price", "");
            rateGCM = sharedPreferences.getString("rate", "");
            nameGCM = sharedPreferences.getString("name", "");
            recipientProfileGCM = sharedPreferences.getString("chatRecipientUrl", "");
            recipientNameGCM = sharedPreferences.getString("chatRecipientName", "");
            recipientStkidGCM = sharedPreferences.getString("recipientStkid", "");
            recipientTokenGCM = sharedPreferences.getString("recipientToken", "");
            senderTokenGCM = sharedPreferences.getString("senderToken", "");

            Log.i(TAG, " FileName GCM " + fileNameGCM + " " + " Name Rate Price &&&&& *** " + messageGCM + " "
                    + priceGCM + " " + rateGCM);
            if (firstConnect) {
                if (recipientStkidGCM.trim() == recipientStkid.trim()
                        || recipientStkidGCM.equals(recipientStkid)) {
                    MyGcmListenerService.flagSendNoti = false;
                    Log.i(TAG, " " + message);
                    // (1) get today's date
                    start = new Date();
                    SimpleDateFormat oFormat = new SimpleDateFormat("dd MMM HH:mm");
                    timeSend = oFormat.format(start);

                    Log.i(TAG, "First connect " + firstConnect);
                    Log.i(TAG, " File Name GCMMMMMM " + fileNameGCM);
                    /*if (!fileNameGCM.equals("") && !fileNameGCM.equals("null") && !fileNameGCM.equals(null)) {
                    oriFName = saveFileAndImage(fileNameGCM);
                    }*/
                    /*if (fileNameGCM.contains("voice")) {
                    String durationStr;
                    MediaPlayer mPlayer = new MediaPlayer();
                    String voiceFileName = getResources().getString(R.string.url) + "/" + fileNameGCM;
                    try {
                        mPlayer.setDataSource(voiceFileName);
                        mPlayer.prepare();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                            
                    //mPlayer.start();
                    int duration = mPlayer.getDuration();
                    mPlayer.release();
                    duration = (int) Math.ceil(duration / 1024);
                            
                    if (duration < 10) {
                        durationStr = "00:0" + duration;
                    } else {
                        durationStr = "00:" + duration;
                    }
                    StikyChat stikyChat = new StikyChat(recipientProfileGCM, messageGCM, true, timeSend, fileNameGCM.trim(), offerIdGCM, offerStatusGCM, priceGCM, rateGCM, durationStr, null, oriFName);
                    adapter.add(stikyChat);
                    } else {*/
                    StikyChat stikyChat = new StikyChat(recipientProfileGCM, messageGCM, true, timeSend,
                            fileNameGCM.trim(), offerIdGCM, offerStatusGCM, priceGCM, rateGCM, nameGCM, null,
                            oriFName);
                    adapter.add(stikyChat);
                    //  }
                    Log.i(TAG, " First " + message + " " + recipientProfileGCM + " " + timeSend);
                    Log.i(TAG, "User " + txtUserName.getText().toString());

                    adapter.notifyDataSetChanged();
                    lv.setSelection(adapter.getCount() - 1);
                    new regTask2().execute("Obj ");
                } else {
                    /* if (!fileNameGCM.equals("") && !fileNameGCM.equals("null") && !fileNameGCM.equals(null)) {
                    saveFileAndImage(fileNameGCM);
                     }*/
                    Log.i(TAG, "..." + recipientStkidGCM.trim());
                    Log.i(TAG, "&&&" + recipientStkid.trim());
                    Log.i(TAG, "else casee");
                    //notificaton send
                    flagNotifi = true;
                    new regTask2().execute("Notification");
                }
                firstConnect = false;
            }
            lv.setSelection(adapter.getCount() - 1);
        }
    };

    /*edTxtMsg.setOnFocusChangeListener(new View.OnFocusChangeListener() {
    @Override
    public void onFocusChange(View v, boolean hasFocus) {
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        layoutTalk.setLayoutParams(params);
        layoutTalk.setGravity(Gravity.CENTER);
      Toast.makeText(getBaseContext(),
                ((EditText) v).getId() + " has focus - " + hasFocus,
                Toast.LENGTH_LONG).show();
    }
    });*/
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    edTxtMsg.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT, 0);
            params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            layoutTalk.setLayoutParams(params);
            layoutTalk.setGravity(Gravity.CENTER);
            flagRecord = false;
            /*getWindow().setSoftInputMode(
                WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
            );*/
            Toast.makeText(getBaseContext(), "Touch ...", Toast.LENGTH_LONG).show();
            return false;
        }
    });
}

From source file:acn.android.framework.view.helper.SlidingTabLayout.java

private void populateTabStrip(float tabTitleSize, ColorStateList textColorStateList) {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;//from   www  .j  ava 2  s  . c o m
        AcnTextView tabTitleView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (AcnTextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && AcnTextView.class.isInstance(tabView)) {
            tabTitleView = (AcnTextView) tabView;
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        tabView.setOnClickListener(tabClickListener);

        ////////TAB CUSTOMIZATIONS///////
        if (mDistributeEvenly) {
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
            lp.width = 0;
            lp.weight = 1;
        }

        if (i == mViewPager.getCurrentItem()) {
            tabView.setSelected(true);
        }

        tabTitleView.setHorizontalFadingEdgeEnabled(true);
        if (!TextUtils.isEmpty(Config.appFont))
            tabTitleView
                    .setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/" + Config.appFont));
        tabTitleView.setTextColor(textColorStateList);
        tabTitleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTitleSize);

        /*WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        int widthInPx = Math.min(display.getHeight(), display.getWidth()); //ACCORDING TO MINIMUM WIDTH-ED SIDE
        tabTitleView.setLayoutParams(new LinearLayout.LayoutParams(widthInPx / 3, LayoutParams.WRAP_CONTENT));*/
        /////////////////////////////////

        mTabStrip.addView(tabView);
    }
}

From source file:net.evendanan.android.hagarfingerpainting.HagarFingerpaintingActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_NEW_PAPER:
        final Dialog newPaper = new Dialog(this);
        newPaper.setTitle(R.string.new_paper_dialog_title);
        newPaper.setContentView(R.layout.new_paper_dialog);
        newPaper.setCancelable(true);//w  ww  .j  a v a2 s .  com
        final EditText painterName = (EditText) newPaper.findViewById(R.id.painter_name_input_text);
        Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/schoolbell.ttf");
        painterName.setTypeface(tf);

        final Gallery colors = (Gallery) newPaper.findViewById(R.id.colors_list);
        colors.setAdapter(new PaperColorListAdapter(getApplicationContext()));
        colors.setOnItemSelectedListener(new OnItemSelectedListener() {
            private View mSelectedItem = null;

            @Override
            public void onItemSelected(AdapterView<?> adapter, View v, int position, long id) {
                if (mSelectedItem != null)
                    mSelectedItem.setBackgroundDrawable(null);

                mSelectedItem = v;
                if (mSelectedItem != null)
                    mSelectedItem.setBackgroundResource(R.drawable.selected_color_background);
            }

            @Override
            public void onNothingSelected(AdapterView<?> arg0) {
                if (mSelectedItem != null)
                    mSelectedItem.setBackgroundDrawable(null);
            }
        });

        colors.setSelection(2);

        View createButton = newPaper.findViewById(R.id.new_paper_create_button);
        createButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
                Editor e = sp.edit();

                final CharSequence painterNameFromUI = painterName.getText().toString();
                final String newPainterName = TextUtils.isEmpty(painterNameFromUI)
                        ? getString(R.string.settings_key_painter_name_default_value)
                        : painterNameFromUI.toString();
                e.putString(getString(R.string.settings_key_painter_name), newPainterName);

                e.commit();

                PaperBackground paper = (PaperBackground) colors.getSelectedItem();

                newPaper.dismiss();

                createNewPaper(paper);
            }
        });
        View cancelButton = newPaper.findViewById(R.id.new_paper_cancel_button);
        cancelButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                newPaper.dismiss();
                if (!mPaperCreated)
                    HagarFingerpaintingActivity.this.finish();
            }
        });
        newPaper.setOnCancelListener(new OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                if (!mPaperCreated)
                    HagarFingerpaintingActivity.this.finish();
            }
        });

        return newPaper;
    default:
        return super.onCreateDialog(id);
    }
}

From source file:com.mobicage.rogerthat.plugins.friends.ServiceActionMenuActivity.java

@Override
protected void onServiceBound() {
    L.d("ServiceActionMenuActivity onServiceBound()");
    final Typeface faTypeFace = Typeface.createFromAsset(getAssets(), "FontAwesome.ttf");
    final int defaultFirstRowTextColor = Color.parseColor("#646464");

    final FriendsPlugin friendsPlugin = mService.getPlugin(FriendsPlugin.class);
    final ServiceMenu menu = friendsPlugin.getStore().getMenu(email, page);

    TableLayout menu_table = (TableLayout) findViewById(R.id.menu_table);
    int tableWidth = menu_table.getWidth();
    for (int x = 0; x < 4; x++) {
        for (int y = 0; y < 3; y++) {
            android.view.ViewGroup cellLayout = (android.view.ViewGroup) findViewById(
                    getResources().getIdentifier("menu_" + x + "x" + y, "id", getPackageName()));
            android.view.ViewGroup.LayoutParams lp = cellLayout.getLayoutParams();
            lp.width = tableWidth / 4;//from www  .j  av  a 2 s.  c o  m
            cellLayout.setLayoutParams(lp);
            Cell cell = new Cell();
            cell.icon = (ImageView) cellLayout.findViewById(R.id.icon);
            cell.faIcon = (TextView) cellLayout.findViewById(R.id.fa_icon);
            cell.label = (TextView) cellLayout.findViewById(R.id.label);
            cells[x][y] = cell;
            if (y == 0) {
                cell.icon.setVisibility(View.GONE);
                cell.faIcon.setTypeface(faTypeFace);
                cell.faIcon.setTextColor(defaultFirstRowTextColor);
                switch (x) {
                case 0:
                    cell.faIcon.setVisibility(View.VISIBLE);
                    cell.faIcon.setText(R.string.fa_info);
                    break;
                case 1:
                    cell.faIcon.setVisibility(View.VISIBLE);
                    cell.faIcon.setText(R.string.fa_envelope);
                    break;
                case 2:
                    cell.faIcon.setVisibility(View.INVISIBLE);
                    cell.faIcon.setText(R.string.fa_phone);
                    break;
                case 3:
                    cell.faIcon.setVisibility(View.INVISIBLE);
                    cell.faIcon
                            .setText(CloudConstants.isYSAAA() ? R.string.fa_qrcode : R.string.fa_thumbs_o_up);
                    break;

                default:
                    break;
                }
            }
        }
    }
    for (int y = 0; y < 3; y++) {
        TableRow row = (TableRow) findViewById(getResources().getIdentifier("row" + y, "id", getPackageName()));
        tableRows[y] = row;
    }
    clearScreen();

    populateScreen(menu);
    IntentFilter filter = new IntentFilter(FriendsPlugin.FRIEND_UPDATE_INTENT);
    filter.addAction(FriendsPlugin.FRIEND_REMOVED_INTENT);
    filter.addAction(FriendsPlugin.FRIEND_MARKED_FOR_REMOVAL_INTENT);
    filter.addAction(MessagingPlugin.NEW_MESSAGE_RECEIVED_INTENT);
    filter.addAction(MessagingPlugin.MESSAGE_PROCESSED_INTENT);
    filter.addAction(MessagingPlugin.MESSAGE_LOCKED_INTENT);
    filter.addAction(MessagingPlugin.MESSAGE_DIRTY_CLEANED_INTENT);
    filter.addAction(MessagingPlugin.THREAD_DELETED_INTENT);
    filter.addAction(MessagingPlugin.THREAD_RECOVERED_INTENT);
    filter.addAction(BrandingMgr.SERVICE_BRANDING_AVAILABLE_INTENT);
    filter.addAction(BrandingMgr.GENERIC_BRANDING_AVAILABLE_INTENT);
    filter.addAction(MessagingPlugin.MESSAGE_JSMFR_ERROR);
    registerReceiver(mBroadcastReceiver, filter);

    findViewById(R.id.navigation_bar_home_button).setOnClickListener(new SafeViewOnClickListener() {
        @Override
        public void safeOnClick(View v) {
            Intent i = new Intent(ServiceActionMenuActivity.this, HomeActivity.class);
            i.setFlags(MainActivity.FLAG_CLEAR_STACK);
            startActivity(i);
            finish();
        }
    });
}

From source file:com.cecs492a_group4.sp.SingleEvent.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_single_event);
    listView = (ListView) findViewById(R.id.listView);
    buildGoogleApiClient();//from  ww  w. ja  v a  2 s.co m
    autocompleteFragment = (PlaceAutocompleteFragment) getFragmentManager()
            .findFragmentById(R.id.autocomplete_fragment);
    autocompleteFragment.getView().setBackgroundColor(Color.WHITE);

    shareDialog = new ShareDialog(this);
    callbackManager = CallbackManager.Factory.create();

    locationSwitch = (Switch) findViewById(R.id.locationSwitch);
    // Register a listener to receive callbacks when a place has been selected or an error has
    // occurred.
    if (staticAddress != null) {

        finalAddress = staticAddress;
        autocompleteFragment.setHint(staticAddress);

        Toast.makeText(this, "Using GSM location", Toast.LENGTH_SHORT).show();

    } else {
        locationSwitch.toggle();
        Toast.makeText(this, ("Please enter a location"), Toast.LENGTH_SHORT).show();

    }

    locationSwitch.setOnCheckedChangeListener(this);
    yelp.setLimit(limit);
    autocompleteFragment.setOnPlaceSelectedListener(this);

    fullButton = (Button) findViewById(R.id.fulldaybtn);
    singleButton = (Button) findViewById(R.id.singleDayBtn);
    Typeface buttonfont = Typeface.createFromAsset(getAssets(), "PoisonedApples.ttf");
    fullButton.setTypeface(buttonfont);
    singleButton.setTypeface(buttonfont);

    //String htmlexample = "<body><h2>The Result<br></h2>";
    //tv.setText(Html.fromHtml(htmlexample, null, null));
    arrayAdapter = new MyDayListAdapter();
    listView.setAdapter(arrayAdapter);
    fullButton.setOnClickListener(this);
    singleButton.setOnClickListener(this);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            DayEvent clickedevent = dayevent.get(position);
            try {
                Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(clickedevent.url));
                startActivity(myIntent);
            } catch (Exception e) {
                System.out.println("Been in on click method");
            }
        }
    });

    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information
    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}

From source file:it.mb.whatshare.Dialogs.java

/**
 * Shows a dialog containing the code received by goo.gl if any, or an error
 * message stating that the pairing operation failed.
 * //from w w w. j  av a2s. c  om
 * @param googl
 *            the pairing code retrieved by goo.gl
 * @param activity
 *            the caller activity
 */
public static void onObtainPairingCode(final String googl, final MainActivity activity) {
    new PatchedDialogFragment() {
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            AlertDialog.Builder builder = getBuilder(activity);
            if (googl != null) {
                View layout = View.inflate(getContext(), R.layout.pairing_code_dialog, null);
                TextView message = (TextView) layout.findViewById(R.id.pairingCode);
                Typeface typeFace = Typeface.createFromAsset(activity.getAssets(), CUSTOM_TYPEFACE_PATH);
                message.setTypeface(typeFace);
                message.setText(googl);
                builder.setView(layout);
            } else {
                builder.setMessage(getResources().getString(R.string.code_dialog_fail));
            }
            builder.setPositiveButton(android.R.string.ok, new OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (googl != null) {
                        Resources res = getResources();
                        String howManyTotal = res.getQuantityString(R.plurals.added_device,
                                activity.getInboundDevicesCount(), activity.getInboundDevicesCount());
                        Toast.makeText(getActivity(), res.getString(R.string.device_paired, howManyTotal),
                                Toast.LENGTH_LONG).show();
                    }
                }
            });
            return builder.create();
        }
    }.show(activity.getSupportFragmentManager(), "resultCode");
}

From source file:gov.wa.wsdot.android.wsdot.ui.traveltimes.TravelTimesFragment.java

public static View makeTravelTimeView(TravelTimeEntity time, 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 via label
    ((TextView) cv.findViewById(R.id.title)).setText("Via " + time.getVia());

    TextView currentTimeTextView = cv.findViewById(R.id.current_value);
    currentTimeTextView.setTypeface(tfb);

    // set updated
    ((TextView) cv.findViewById(R.id.updated))
            .setText(ParserUtils.relativeTime(time.getUpdated(), "yyyy-MM-dd HH:mm a", false));

    if (time.getStatus().toLowerCase().equals("closed")) {
        currentTimeTextView.setText("Closed");
        currentTimeTextView.setTextColor(Color.RED);
        cv.findViewById(R.id.subtitle).setVisibility(View.GONE);
    } else {/*from   w  w  w  .  j  a  v  a2 s.  co  m*/

        // set distance and avg time text view
        String average_time;
        String distance = time.getDistance();
        int average = time.getAverage();

        if (average == 0) {
            average_time = "Not Available";
        } else {
            average_time = average + " min";
        }

        ((TextView) cv.findViewById(R.id.subtitle)).setText(distance + " / " + average_time);

        // set current travel time. Set to closed if status is closed.
        int current = time.getCurrent();

        if (current < average) {
            currentTimeTextView.setTextColor(0xFF008060);
        } else if ((current > average) && (average != 0)) {
            currentTimeTextView.setTextColor(Color.RED);
        } else {
            currentTimeTextView.setTextColor(Color.BLACK);
        }

        currentTimeTextView.setText(current + " min");

    }
    return cv;

}