List of usage examples for android.graphics Typeface createFromAsset
public static Typeface createFromAsset(AssetManager mgr, String path)
From source file:br.com.projeto.icebeer.MainFragment.java
private void updateTemperatura() { if (--temperatura < -5) { temperatura = 5.0;/*from ww w . ja v a2s .co m*/ } Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "fonts/digital-7.ttf"); TextView tx = (TextView) getActivity().findViewById(R.id.txtTemperatura); tx.setText(String.valueOf(temperatura)); tx.setTextSize(80); tx.setTypeface(tf); TextView sw = (TextView) getActivity().findViewById(R.id.shadowTemperatura); sw.setText("88.8"); sw.setTextSize(80); sw.setTypeface(tf); }
From source file:com.dm.material.dashboard.candybar.fragments.dialog.WallpaperOptionsFragment.java
@Override public void onClick(View view) { int id = view.getId(); int color = ColorHelper.getAttributeColor(getActivity(), R.attr.colorAccent); if (id == R.id.apply) { WallpaperHelper.applyWallpaper(getActivity(), null, color, mUrl, mName); } else if (id == R.id.save) { if (PermissionHelper.isPermissionStorageGranted(getActivity())) { File target = new File(WallpaperHelper.getDefaultWallpapersDirectory(getActivity()).toString() + File.separator + mName + FileHelper.IMAGE_EXTENSION); if (target.exists()) { Context context = getActivity(); CafeBar.builder(getActivity()) .theme(new CafeBarTheme.Custom( ColorHelper.getAttributeColor(getActivity(), R.attr.card_background))) .autoDismiss(false).maxLines(4) .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(color) .positiveTypeface( Typeface.createFromAsset(getActivity().getAssets(), "fonts/Font-Bold.ttf")) .onPositive(cafeBar -> { if (context == null) { cafeBar.dismiss(); return; }//from w w w . j a va 2 s .c o m WallpaperHelper.downloadWallpaper(context, color, mUrl, mName); cafeBar.dismiss(); }).negativeText(R.string.wallpaper_download_exist_new) .negativeTypeface( Typeface.createFromAsset(getActivity().getAssets(), "fonts/Font-Bold.ttf")) .onNegative(cafeBar -> { if (context == null) { cafeBar.dismiss(); return; } WallpaperHelper.downloadWallpaper(context, color, mUrl, mName + "_" + System.currentTimeMillis()); cafeBar.dismiss(); }).build().show(); dismiss(); return; } WallpaperHelper.downloadWallpaper(getActivity(), color, mUrl, mName); dismiss(); return; } PermissionHelper.requestStoragePermission(getActivity()); } dismiss(); }
From source file:com.example.search.car.pools.welcome.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.welcome);//from ww w .j av a2 s . com Bundle bundle = getIntent().getExtras(); if (bundle != null) { frag_id = bundle.getInt("frag_id"); } tf = Typeface.createFromAsset(welcome.this.getAssets(), "AvenirLTStd_Book.otf"); // for notification // nReceiver = new NotificationReceiver(); // IntentFilter filter = new IntentFilter(); // filter.addAction("com.kpbird.nlsexample.NOTIFICATION_LISTENER_EXAMPLE"); // registerReceiver(nReceiver, filter); task = getSharedPreferences("user", MODE_PRIVATE); SharedPreferences sharedpreferences = this.getPreferences(0); Editor editor = sharedpreferences.edit(); editor.putString("username", userid); editor.commit(); initMenu(); // mTitle = mDrawerTitle = "Search Carpool"; mPlanetTitles = getResources().getStringArray(R.array.menu_array); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (RelativeLayout) findViewById(R.id.left_drawer); // set a custom shadow that overlays the main content when the drawer // opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // mDrawerList.setAdapter(new ArrayAdapter<String>(this, // R.layout.drawer_list_item, mPlanetTitles)); mDrawerList.setOnClickListener(this); // enable ActionBar app icon to behave as action to toggle nav drawer // getActionBar().setTitle(""); // getActionBar().setDisplayHomeAsUpEnabled(true); // getActionBar().setHomeButtonEnabled(true); // getActionBar().setBackgroundDrawable(new // ColorDrawable(Color.parseColor("#0087ca"))); // Drawable d = ContextCompat.getDrawable(welcome.this, // R.drawable.logooo); // getActionBar().setIcon(d); // custom navigation bar getActionBar().setDisplayShowHomeEnabled(false); getActionBar().setDisplayShowTitleEnabled(false); LayoutInflater mInflater = LayoutInflater.from(this); View mCustomView = mInflater.inflate(R.layout.layout_navigation, null); ib_back = (ImageButton) mCustomView.findViewById(R.id.ib_navigation_back); ib_handle = (ImageButton) mCustomView.findViewById(R.id.ib_navigation_handle); ib_logo = (ImageButton) mCustomView.findViewById(R.id.ib_navigation_logo); ib_search = (ImageButton) mCustomView.findViewById(R.id.ib_navigation_search); ib_menu = (ImageButton) mCustomView.findViewById(R.id.ib_navigation_menu); l_back = (LinearLayout) mCustomView.findViewById(R.id.l_navigation_back); l_handle = (LinearLayout) mCustomView.findViewById(R.id.l_navigation_handle); l_logo = (LinearLayout) mCustomView.findViewById(R.id.l_navigation_logo); l_nav_search = (LinearLayout) mCustomView.findViewById(R.id.l_navigation_search); l_menu = (LinearLayout) mCustomView.findViewById(R.id.l_navigation_menu); d1 = ContextCompat.getDrawable(welcome.this, R.drawable.touch_ripple_back_color); d2 = ContextCompat.getDrawable(welcome.this, R.drawable.touch_blue_back_color); l_back.setBackground(d2); l_handle.setBackground(d2); l_logo.setBackground(d2); l_nav_search.setBackground(d2); l_menu.setBackground(d2); ib_back.setOnClickListener(this); ib_handle.setOnClickListener(this); ib_logo.setOnClickListener(this); ib_search.setOnClickListener(this); ib_menu.setOnClickListener(this); l_back.setOnClickListener(this); l_handle.setOnClickListener(this); l_logo.setOnClickListener(this); l_nav_search.setOnClickListener(this); l_menu.setOnClickListener(this); // l_handle.setOnTouchListener(new OnTouchListener() { // // @Override // public boolean onTouch(View v, MotionEvent event) { // // TODO Auto-generated method stub // if (event.getAction() == MotionEvent.ACTION_DOWN){ // v.setBackgroundResource(R.drawable.touch_ripple_back_color); // } else if (event.getAction() == MotionEvent.ACTION_UP){ // v.setBackgroundResource(R.drawable.touch_blue_back_color); // } // return true; // } // }); // ib_handle.setOnTouchListener(new OnTouchListener() { // // @Override // public boolean onTouch(View v, MotionEvent event) { // // TODO Auto-generated method stub // final int DELAY = 200; // ColorDrawable f = new ColorDrawable(Color.parseColor("#0087ca")); // ColorDrawable f1 = new ColorDrawable(Color.parseColor("#3398ca")); // Drawable d1 = // ContextCompat.getDrawable(welcome.this,R.drawable.touch_ripple_back_color); // Drawable d2 = // ContextCompat.getDrawable(welcome.this,R.drawable.touch_blue_back_color); // AnimationDrawable a = new AnimationDrawable(); // a.addFrame(f1, DELAY); // a.addFrame(f, DELAY); // a.setOneShot(true); // l_handle.setBackground(a); // a.start(); // if (mDrawerLayout.isDrawerOpen(GravityCompat.START) && // event.getAction() == MotionEvent.ACTION_UP) { // mDrawerLayout.closeDrawer(mDrawerList); // } else { // mDrawerLayout.openDrawer(mDrawerList); // } // // return true; // } // }); SVG svg_back = SVGParser.getSVGFromResource(getResources(), R.raw.actionbar_back); SVG svg_handle = SVGParser.getSVGFromResource(getResources(), R.raw.actionbar_menu); SVG svg_logo = SVGParser.getSVGFromResource(getResources(), R.raw.logo_splash); SVG svg_search = SVGParser.getSVGFromResource(getResources(), R.raw.actionbar_search); SVG svg_menu = SVGParser.getSVGFromResource(getResources(), R.raw.actionbar_triple_dot); ib_back.setImageDrawable(svg_back.createPictureDrawable()); ib_handle.setImageDrawable(svg_handle.createPictureDrawable()); ib_logo.setImageDrawable(svg_logo.createPictureDrawable()); ib_search.setImageDrawable(svg_search.createPictureDrawable()); ib_menu.setImageDrawable(svg_menu.createPictureDrawable()); // int colorFrom = Color.parseColor("#0087ca"); // int colorTo = Color.parseColor("#3398ca"); // ValueAnimator colorAnimation = ValueAnimator.ofObject(new // ArgbEvaluator(), colorFrom,colorTo); // colorAnimation.addUpdateListener(new AnimatorUpdateListener() { // // @Override // public void onAnimationUpdate(ValueAnimator animator) { // // TODO Auto-generated method stub // l_handle.setBackgroundColor((Integer) animator.getAnimatedValue()); // } // }); // l_handle.setOnClickListener(new OnClickListener() { // // @Override // public void onClick(View v) { // // TODO Auto-generated method stub // // } // }); l_back.setVisibility(View.GONE); // popup = new PopupMenu(welcome.this, ib_menu); // l_menu.setOnClickListener(new OnClickListener() { // // @Override // public void onClick(View v) { // // TODO Auto-generated method stub // // } // }); // l_search.setOnClickListener(new OnClickListener() { // // @Override // public void onClick(View v) { // // TODO Auto-generated method stub // // } // }); getActionBar().setCustomView(mCustomView); getActionBar().setDisplayShowCustomEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawerxx, /* * nav drawer image to replace 'Up' * caret */ R.string.drawer_open, /* * "open drawer" description for * accessibility */ R.string.drawer_close /* * "close drawer" description for * accessibility */ ) { public void onDrawerClosed(View view) { // getActionBar().setTitle("Search Carpool"); invalidateOptionsMenu(); // creates call to // onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { // getActionBar().setTitle("Search Carpool"); invalidateOptionsMenu(); // creates call to // onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(frag_id); } }
From source file:com.sith.login.FBLoginActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getActionBar().setDisplayHomeAsUpEnabled(true); // redirectState=getIntent().getExtras().getString("riderect_state"); isConnect = getIntent().getExtras().getBoolean("isConnect"); uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); if (savedInstanceState != null) { String name = savedInstanceState.getString(PENDING_ACTION_BUNDLE_KEY); pendingAction = PendingAction.valueOf(name); }/*from www .j a v a 2 s. co m*/ setContentView(R.layout.login); FragmentManager fm1 = getSupportFragmentManager(); fragments[LOGINMETHOD] = fm1.findFragmentById(R.id.loginMethodFragment); fragments[PROFILE] = fm1.findFragmentById(R.id.profileFragment); FragmentTransaction transaction = fm1.beginTransaction(); for (int i = 0; i < fragments.length; i++) { transaction.hide(fragments[i]); } transaction.commit(); loginButton = (LoginButton) findViewById(R.id.login_button); List<String> additionalPermissions = new ArrayList<String>(); additionalPermissions.add("publish_stream"); additionalPermissions.add("publish_actions"); loginButton.setPublishPermissions(additionalPermissions); loginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() { // @Override public void onUserInfoFetched(GraphUser user) { FBLoginActivity.this.user = user; updateUserInfo(); // It's possible that we were waiting for this.user to // be populated in order to post a // status update. handlePendingAction(); } }); profilePictureViewFB = (ProfilePictureView) findViewById(R.id.profilePictureFB); greeting = (TextView) findViewById(R.id.greeting); controlsContainer = (ViewGroup) findViewById(R.id.main_ui_container); final FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(R.id.fragment_container); if (fragment != null) { // If we're being re-created and have a fragment, we need to a) hide // the main UI controls and // b) hook up its listeners again. controlsContainer.setVisibility(View.GONE); } // Listen for changes in the back stack so we know if a fragment got // popped off because the user // clicked the back button. fm.addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() { // @Override public void onBackStackChanged() { if (fm.getBackStackEntryCount() == 0) { // We need to re-show our UI. controlsContainer.setVisibility(View.VISIBLE); } } }); // Fonts Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Medium.ttf"); greeting.setTypeface(tf); }
From source file:com.nutsuser.ridersdomain.activities.LiveforDream.java
private void setFontsToTextViews() { tvTitleToolbar.setTypeface(Typeface.createFromAsset(getResources().getAssets(), "fonts/MACHINEN.TTF")); textView2.setTypeface(Typeface.createFromAsset(getResources().getAssets(), "fonts/Lato-Heavy.ttf")); textView3.setTypeface(Typeface.createFromAsset(getResources().getAssets(), "fonts/Lato-Bold.ttf")); tvName.setTypeface(Typeface.createFromAsset(getResources().getAssets(), "fonts/MACHINEN.TTF")); }
From source file:pk.edu.ucp.fall16_mad_c.AdvRecipeAdapter.java
/** * Get a View that displays the data at the specified position in the data set. You can either * create a View manually or inflate it from an XML layout file. When the View is inflated, the * parent View (GridView, ListView...) will apply default layout parameters unless you use * {@link LayoutInflater#inflate(int, ViewGroup, boolean)} * to specify a root view and to prevent attachment to the root. * * @param position The position of the item within the adapter's data set of the item whose view * we want./* w ww . j av a 2 s .c om*/ * @param convertView The old view to reuse, if possible. Note: You should check that this view * is non-null and of an appropriate type before using. If it is not possible to convert * this view to display the correct data, this method can create a new view. * Heterogeneous lists can specify their number of view types, so that this View is * always of the right type (see {@link #getViewTypeCount()} and * {@link #getItemViewType(int)}). * @param parent The parent that this view will eventually be attached to * @return A View corresponding to the data at the specified position. */ @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; // check if the view already exists if so, no need to inflate and findViewById again! if (convertView == null) { // Inflate the custom row layout from your XML. convertView = mInflater.inflate(R.layout.list_item_complex, parent, false); // create a new "Holder" with subviews holder = new ViewHolder(); holder.thumbnailImageView = (ImageView) convertView.findViewById(R.id.recipe_list_thumbnail); holder.titleTextView = (TextView) convertView.findViewById(R.id.recipe_list_title); holder.subtitleTextView = (TextView) convertView.findViewById(R.id.recipe_list_subtitle); holder.detailTextView = (TextView) convertView.findViewById(R.id.recipe_food_type); // hang onto this holder for future recyclage convertView.setTag(holder); Log.d(TAG, "CreateCount = " + ++createCount); } else { // skip all the expensive inflation/findViewById and just get the holder you already made holder = (ViewHolder) convertView.getTag(); } // Get relevant subviews of row view TextView titleTextView = holder.titleTextView; TextView subtitleTextView = holder.subtitleTextView; TextView detailTextView = holder.detailTextView; ImageView thumbnailImageView = holder.thumbnailImageView; //Get corresponding recipe for row Recipe recipe = (Recipe) getItem(position); // Update row view's textviews to display recipe information titleTextView.setText(recipe.title); subtitleTextView.setText(recipe.description); detailTextView.setText(recipe.foodType); if (position % 2 == 0) { thumbnailImageView.setImageResource(R.drawable.bouncing_ball_00); } else { thumbnailImageView.setImageResource(R.drawable.arrow); } // Style text views Typeface titleTypeFace = Typeface.createFromAsset(mContext.getAssets(), "fonts/JosefinSans-Bold.ttf"); titleTextView.setTypeface(titleTypeFace); Typeface subtitleTypeFace = Typeface.createFromAsset(mContext.getAssets(), "fonts/JosefinSans-SemiBoldItalic.ttf"); subtitleTextView.setTypeface(subtitleTypeFace); Typeface detailTypeFace = Typeface.createFromAsset(mContext.getAssets(), "fonts/Quicksand-Bold.otf"); detailTextView.setTypeface(detailTypeFace); detailTextView.setTextColor(android.support.v4.content.ContextCompat.getColor(mContext, R.color.red)); return convertView; }
From source file:com.arctech.stikyhive.ChattingActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { 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"); pref = PreferenceManager.getDefaultSharedPreferences(this); ws = new JsonWebService(); dbHelper = new DBHelper(this); dialog = new ProgressDialog(this); listChatContact = new ArrayList<>(); listChatContact = dbHelper.getChatContact(); Log.i(" Chat Contact ", " " + listChatContact.size()); //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)); }//w w w . j ava 2s . c o m start = new Date(); SimpleDateFormat oFormat = new SimpleDateFormat("dd MMM HH:mm"); timeSend = oFormat.format(start); super.onCreate(savedInstanceState); setContentView(R.layout.chat); 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); // lv.smoothScrollToPosition(adapter.getCount() - 1); 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(getApplicationContext(), R.layout.messaging_listview, faceSemi_bold, faceRegular); 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 (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 = ""; if (chatRecipientUrl.contains("http")) { url = chatRecipientUrl; } else { 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 (StikyChatTb chatTb : listHistory) { String getDate = chatTb.getSendDate(); String fromStikyBee = chatTb.getSender(); try { String createDate = dateFormat2.format(dateFormat.parse(getDate)); if (fromStikyBee.equals(pref.getString("stkid", ""))) { adapter.add(new StikyChat(chatRecipientUrl, chatTb.getMessage(), false, createDate, "")); } else { adapter.add(new StikyChat(chatRecipientUrl, chatTb.getMessage(), true, createDate, "")); } 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); messageGCM = sharedPreferences.getString("message", ""); recipientProfileGCM = sharedPreferences.getString("chatRecipientUrl", ""); recipientNameGCM = sharedPreferences.getString("chatRecipientName", ""); recipientStkidGCM = sharedPreferences.getString("recipientStkid", ""); recipientTokenGCM = sharedPreferences.getString("recipientToken", ""); senderTokenGCM = sharedPreferences.getString("senderToken", ""); Log.i(TAG, "..." + recipientStkidGCM.trim() + " STKID " + recipientStkid.trim() + ":"); 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); StikyChat stikyChat = new StikyChat(recipientProfileGCM, messageGCM, true, timeSend, ""); Log.i(TAG, " First " + message + " " + recipientProfileGCM + " " + timeSend); Log.i(TAG, "User " + txtUserName.getText().toString()); //txtUserName.setText(message); Log.i(TAG, "User 2 " + txtUserName.getText().toString()); adapter.add(stikyChat); adapter.notifyDataSetChanged(); //new regTask2().execute("Obj "); lv.smoothScrollToPosition(adapter.getCount() - 1); } else { 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; } } }; }
From source file:weathernotificationservice.wns.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // Initialize the associated SharedPreferences file with default values PreferenceManager.setDefaultValues(this, R.xml.prefs, false); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); setTheme(theme = getTheme(prefs.getString("theme", "fresh"))); boolean darkTheme = theme == R.style.AppTheme_NoActionBar_Dark || theme == R.style.AppTheme_NoActionBar_Classic_Dark; // Initiate activity super.onCreate(savedInstanceState); setContentView(R.layout.activity_scrolling); appView = findViewById(R.id.viewApp); progressDialog = new ProgressDialog(MainActivity.this); //Load toolbar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from w w w.j a va 2 s.c o m*/ if (darkTheme) { toolbar.setPopupTheme(R.style.AppTheme_PopupOverlay_Dark); } // Initialize textboxes todayTemperature = (TextView) findViewById(R.id.todayTemperature); todayDescription = (TextView) findViewById(R.id.todayDescription); todayWind = (TextView) findViewById(R.id.todayWind); todayPressure = (TextView) findViewById(R.id.todayPressure); todayHumidity = (TextView) findViewById(R.id.todayHumidity); todaySunrise = (TextView) findViewById(R.id.todaySunrise); todaySunset = (TextView) findViewById(R.id.todaySunset); lastUpdate = (TextView) findViewById(R.id.lastUpdate); todayIcon = (TextView) findViewById(R.id.todayIcon); weatherFont = Typeface.createFromAsset(this.getAssets(), "fonts/weather.ttf"); todayIcon.setTypeface(weatherFont); // Initialize viewPager viewPager = (ViewPager) findViewById(R.id.viewPager); tabLayout = (TabLayout) findViewById(R.id.tabs); destroyed = false; initMappings(); // Preload data from cache preloadWeather(); updateLastUpdateTime(); // Set autoupdater AlarmReceiver.setRecurringAlarm(this); }
From source file:selfie.time.HelloFacebookSampleActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); if (savedInstanceState != null) { String name = savedInstanceState.getString(PENDING_ACTION_BUNDLE_KEY); pendingAction = PendingAction.valueOf(name); }//from www. j a va2s. co m context = this; setContentView(R.layout.main); try { PackageInfo info = context.getPackageManager().getPackageInfo("selfie.time", PackageManager.GET_SIGNATURES); //Your package name here for (Signature signature : info.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); Log.e("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT)); } } catch (NameNotFoundException e) { } catch (NoSuchAlgorithmException e) { } final Typeface mFont = Typeface.createFromAsset(getAssets(), "bg.otf"); final ViewGroup mContainer = (ViewGroup) findViewById(android.R.id.content).getRootView(); Util.setAppFont(mContainer, mFont, false); et = (EditText) findViewById(R.id.editText1); loginButton = (LoginButton) findViewById(R.id.login_button); loginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() { @Override public void onUserInfoFetched(GraphUser user) { HelloFacebookSampleActivity.this.user = user; updateUI(); handlePendingAction(); } }); profilePictureView = (ProfilePictureView) findViewById(R.id.profilePicture); greeting = (TextView) findViewById(R.id.greeting); postStatusUpdateButton = (Button) findViewById(R.id.postStatusUpdateButton); postStatusUpdateButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Session session = Session.getActiveSession(); if (session != null) onClickPostStatusUpdate(); else Util.showInfoDialog(context, "Please login with Facebook first."); } }); postPhotoButton = (Button) findViewById(R.id.postPhotoButton); postPhotoButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPostPhoto(); } }); pickFriendsButton = (Button) findViewById(R.id.pickFriendsButton); pickFriendsButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { onClickPickFriends(); } }); postSelfieButton = (Button) findViewById(R.id.postSelfieButton); postSelfieButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Session session = Session.getActiveSession(); if (!Util.isNetworkAvailable(context)) Util.showWifiDialog(context); else if (et.getText().toString().length() == 0) Util.showInfoDialog(context, "Please enter text to share with this selfie."); else if (session == null || !session.isOpened()) Util.showInfoDialog(context, "Please login with Facebook first."); else initCapturePhoto(REQUEST_IMAGE_CAPTURE); } }); controlsContainer = (ViewGroup) findViewById(R.id.main_ui_container); final FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(R.id.fragment_container); if (fragment != null) { // If we're being re-created and have a fragment, we need to a) hide the main UI controls and // b) hook up its listeners again. controlsContainer.setVisibility(View.GONE); if (fragment instanceof FriendPickerFragment) { setFriendPickerListeners((FriendPickerFragment) fragment); } else if (fragment instanceof PlacePickerFragment) { setPlacePickerListeners((PlacePickerFragment) fragment); } } // Listen for changes in the back stack so we know if a fragment got popped off because the user // clicked the back button. fm.addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() { @Override public void onBackStackChanged() { if (fm.getBackStackEntryCount() == 0) { // We need to re-show our UI. controlsContainer.setVisibility(View.VISIBLE); } } }); // Can we present the share dialog for regular links? canPresentShareDialog = FacebookDialog.canPresentShareDialog(this, FacebookDialog.ShareDialogFeature.SHARE_DIALOG); // Can we present the share dialog for photos? canPresentShareDialogWithPhotos = FacebookDialog.canPresentShareDialog(this, FacebookDialog.ShareDialogFeature.PHOTOS); }
From source file:com.plusapp.pocketbiceps.app.MainActivity.java
@TargetApi(Build.VERSION_CODES.N) @Override/* www .j av a 2s . c o m*/ protected void onCreate(Bundle savedInstanceState) { SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); String theme_key = getString(R.string.preference_key_darktheme); isSetToDarkTheme = sPrefs.getBoolean(theme_key, false); if (isSetToDarkTheme == true) { setTheme(R.style.DarkTheme); isDarkTheme = true; } // Prueft ob das Coverfoto gesetzt werden soll und speichert es ggfs. in einer Bitmap String cover_key = getString(R.string.preference_key_coverphoto); isSettoCoverPhoto = sPrefs.getBoolean(cover_key, false); //Oeffnet die Datenbank data = new MarkerDataSource(this); data.open(); // data.addMarker(new MyMarkerObj("Test", "Test2", "48.49766 9.19881", 1234234)); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); // Aenderd den Textfont von der Toolbar for (int i = 0; i < toolbar.getChildCount(); i++) { View view = toolbar.getChildAt(i); if (view instanceof TextView) { TextView tv = (TextView) view; Typeface titleFont = Typeface.createFromAsset(getAssets(), "fonts/Antonio-Light.ttf"); if (tv.getText().equals(toolbar.getTitle())) { // Zum zentrieren // Toolbar.LayoutParams params = new Toolbar.LayoutParams(Toolbar.LayoutParams.WRAP_CONTENT, Toolbar.LayoutParams.MATCH_PARENT); // params.gravity = Gravity.CENTER_HORIZONTAL; // tv.setLayoutParams(params); // Zum aendern der Schriftart tv.setTypeface(titleFont); tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 28); break; } } } sp = getSharedPreferences("prefs_sort", Activity.MODE_PRIVATE); sortOrder = sp.getInt("sort_mode", 0); //Permissions Abfragen isStoragePermissionGranted(); grantLocationPermission(); // Erstellt die RecylerView recList = (RecyclerView) findViewById(R.id.lvMemories); recList.setHasFixedSize(true); LinearLayoutManager llm = new LinearLayoutManager(this); llm.setOrientation(LinearLayoutManager.VERTICAL); recList.setLayoutManager(llm); momentsCount = createList2().size(); fab_Menu = (FloatingActionMenu) findViewById(R.id.fab_menu); fab1 = (FloatingActionButton) findViewById(R.id.fab1); fab2 = (FloatingActionButton) findViewById(R.id.fab2); fab3 = (FloatingActionButton) findViewById(R.id.fab3); // An den MemoryAdapter wird Liste an den Konstruktor weitergegeben this.ca = new MemoryAdapter(createList2(), this); this.recList.setAdapter(ca); final String PREFS_NAME = "MyPrefsFile"; SharedPreferences firstPref = getSharedPreferences(PREFS_NAME, 0); if (firstPref.getBoolean("First_Time", true)) { //Do first operation showMainTutorial(); firstPref.edit().putBoolean("First_Time", false).apply(); } /* Hier wird der clicklListener der weiter unten programmiert ist hinzugefgt damit kann man auf Klick events mit einem Switch reagieren */ fab1.setOnClickListener(clickListener); fab2.setOnClickListener(clickListener); fab3.setOnClickListener(clickListener); /* Gibt an in welcher Geschwindigkeit die normalen Buttons auftauchen sollen */ int delay = 400; for (final FloatingActionMenu menu : fab_Submenus) { mUiHandler.postDelayed(new Runnable() { @Override public void run() { menu.showMenuButton(true); } }, delay); delay += 150; } /* Das toggle sorgt dafr dass der Menbutton aufgeklappt und zugeklappt werden kann */ fab_Menu.setOnMenuButtonClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (fab_Menu.isOpened()) { /* Mit getMenuButtonLabelText() bekommt man den Text der in der XML deklariert ist */ // Toast.makeText(getBaseContext(), fab_Menu.getMenuButtonLabelText(), Toast.LENGTH_SHORT).show(); } fab_Menu.toggle(true); } }); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); navigationView = (NavigationView) findViewById(R.id.nav_view); // TextView nav_user = (TextView) headNavView.findViewById(R.id.tvNavHeaderTitle); // nav_user.setText("test1231231"); navigationView.setNavigationItemSelectedListener(this); headNavView = navigationView.getHeaderView(0); nav_image_head = (ImageView) headNavView.findViewById(R.id.ivNavHead); if (isDarkTheme) { nav_image_head.setImageResource(R.drawable.headerblack); } else { nav_image_head.setImageResource(R.drawable.headerblue); } if (isSettoCoverPhoto) { // NavDrawer Header manipulieren List<MyMarkerObj> navHeaderGetImage = createList2(); // Falls mind. ein Eintrag existiert, wird das Foto dass als letztes gemacht wurde // in den NavHeader eingefgt if (navHeaderGetImage.size() != 0) { MyMarkerObj mmo = navHeaderGetImage.get(0); // Das Datum und die Zeit dienen als Index um die Bilder zu finden z.B. Moments_10-12-2016-18-24-10 SimpleDateFormat formatterForImageSearch = new SimpleDateFormat("dd-MM-yyyy-HH-mm-SS"); String imageDate = formatterForImageSearch.format(new Date(mmo.getTimestamp())); // Das Bild wird in die Variable f initialisiert File f = new File(mmo.getPath()); memAdapter = new MemoryAdapter(); bmpHeaderTarget = new Target() { @Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { bmp = bitmap; // Setzt das Bild in den NavHeader wenn bmp not null ist if (bmp != null) { nav_image_head.setImageBitmap(bmp); } } @Override public void onBitmapFailed(Drawable errorDrawable) { } @Override public void onPrepareLoad(Drawable placeHolderDrawable) { } }; Picasso.with(this).load(f).resize(540, 540).centerCrop().into(bmpHeaderTarget); isCoverPhoto = true; } } momentsCounter = (TextView) MenuItemCompat .getActionView(navigationView.getMenu().findItem(R.id.nav_camera)); // Damit wird der Counter initialisiert initializeCountDrawer(); FragmentManager fm = getFragmentManager(); fm.beginTransaction().replace(R.id.content_main, new MainFragment()).commit(); }