我在我的应用程序中使用Spring Social:
<spring.framework.version>3.2.0.RELEASE</spring.framework.version>
<hibernate.version>4.1.9.Final</hibernate.version>
<commons-dbcp.version>1.4</commons-dbcp.version>
<org.springframework.social-version>1.1.0.BUILD-SNAPSHOT</org.springframework.social-version>
<org.springframework.social.facebook-version>1.1.0.BUILD-SNAPSHOT</org.springframework.social.facebook-version>
<org.springframework-version>3.2.1.RELEASE</org.springframework-version>
<org.springframework.security.crypto-version>3.1.3.RELEASE</org.springframework.security.crypto-version>
Run Code Online (Sandbox Code Playgroud)
当我申请
private final Facebook facebook;
@Inject
public SearchController(Facebook facebook) {
this.facebook = facebook;
}
Run Code Online (Sandbox Code Playgroud)
到我的HomeController:
@Controller
public class HomeController {
private final Facebook facebook;
@Inject
public HomeController(Facebook facebook) {
this.facebook = facebook;
}
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
/**
* Simply selects the home view to render by returning its name.
*/
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Model model) {
return "home";
}
}
Run Code Online (Sandbox Code Playgroud)
注射工作就像有意,我可以从中获取信息facebook …
我想为我的应用程序实现更改密码功能.
我包含com.google.firebase:firebase-auth:9.0.2
在我的build.gradle
文件中,到目前为止,一切都工作正常,直到我尝试实现更改密码功能.
我发现该FirebaseUser
对象有一个updatePassword
方法,它接受一个新密码作为参数.我可以使用这种方法并自己实现验证.但是,我需要用户的当前密码与输入的密码进行比较,我找不到获取密码的方法.
我还在对象上找到了另一种方法,Firebase
它接受旧密码,新密码和处理程序.问题是我还需要包括com.firebase:firebase-client-android:2.5.2+
访问这个类,当我尝试这个方法时,我得到以下错误:
在console.firebase.google.com上创建的项目必须使用firebase.google.com/docs/auth/中提供的新Firebase身份验证SDK
觉得我在这里错过了一些东西.实施此建议的方法是什么?什么时候使用什么依赖?
我正在尝试将奇数/偶数选择器应用于类父类的列表中的所有元素.
HTML:
<ul>
<li class="parent">green</li>
<li class="parent">red</li>
<li>ho ho ho</li>
<li class="parent">green</li>
<li class="parent">red</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
CSS:
.parent:nth-child(odd) {
background-color: green;
}
.parent:nth-child(even) {
background-color: red;
}
ul {
width:100px;
height: 100px;
display: block;
}
Run Code Online (Sandbox Code Playgroud)
但颜色正在重置.我希望列表项是文本的颜色.
有没有办法做到这一点?
我很难学习如何将Google OpenId支持集成到我的Spring 3.1 Web应用程序(包括Spring security 3.1).
我找到了一些文档和教程,但它对我没有帮助.
喜欢:
我仍然无法弄清楚如何使这项工作.
在应用程序中获取Google OpenId登录工作所需的组件是什么?我的意思是让这个运行的绝对最低要求是什么?没什么特别的
一个非常简单的例子会很棒.
谢谢
我正试着按照这里的指南:
https://guide.meteor.com/using-packages.html
安装几个节点包,然后尝试将它们导入我的methods.js
文件,但我收到以下错误:
W20160423-15:08:57.338(9)? (STDERR) app/server/methods.js:1
W20160423-15:08:57.338(9)? (STDERR) (function(Npm,Assets){(function(){import Fibers from 'fibers';
W20160423-15:08:57.338(9)? (STDERR) ^^^^^^
W20160423-15:08:57.343(9)? (STDERR) SyntaxError: Unexpected reserved word
W20160423-15:08:57.344(9)? (STDERR) at /repos/myproject/.meteor/local/build/programs/server/boot.js:278:30
W20160423-15:08:57.344(9)? (STDERR) at Array.forEach (native)
W20160423-15:08:57.344(9)? (STDERR) at Function._.each._.forEach (/Volumes/320gb/macbookpro/.meteor/packages/meteor-tool/.1.3.2_4.1rz3z4t++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20160423-15:08:57.345(9)? (STDERR) at /repos/myproject/.meteor/local/build/programs/server/boot.js:133:5
Run Code Online (Sandbox Code Playgroud)
我的包似乎安装正确.不确定是什么导致了这个,这是一个错误吗?
我的菜单项变为红色,10sp,背景为白色,但textStyle
粗体不起作用.为什么是这样?
styles.xml
<style name="toolbarMenuTheme">
<item name="android:colorBackground">@color/white</item>
<item name="android:textColor">@color/red</item>
<item name="android:textSize">10sp</item>
<item name="android:textStyle">bold</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我的布局片段.
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="-5dp"
android:background="@color/white"
android:theme="@style/toolbarMenuTheme"/>
Run Code Online (Sandbox Code Playgroud)
我的膨胀布局.
<item
android:id="@+id/web_view_reload"
android:icon="@drawable/replay"
android:title="Reload"
app:showAsAction="always"/>
<item
android:id="@+id/web_view_action"
android:icon="@drawable/stack_icon_on"
android:title="Stack"
app:showAsAction="always"/>
<item
android:id="@+id/web_view_screenshot"
android:icon="@drawable/screenshot"
android:title="Screenshot"
app:showAsAction="always"/>
<item
android:id="@+id/web_view_share"
android:title="SHARE WEBSITE"/>
<item
android:id="@+id/web_view_copy_url"
android:title="Copy URL"/>
Run Code Online (Sandbox Code Playgroud)
用java填充它:
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setNavigationIcon(R.drawable.x);
toolbar.inflateMenu(R.menu.web_view_toolbar_menu);
Run Code Online (Sandbox Code Playgroud)
并设置单击侦听器:
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
....
}
}
Run Code Online (Sandbox Code Playgroud)
评论后编辑
这是我的完整styles.xml
Styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomUITheme" parent="@style/Theme.AppCompat.Light.NoActionBar"> …
Run Code Online (Sandbox Code Playgroud) 我使用connectGatt()
Android中的方法连接到BLE设备.这非常有效.
当我断开连接时,请使用以下内容:
private void disconnectDevice() {
gatt.disconnect();
}
Run Code Online (Sandbox Code Playgroud)
当我收到回调时,我会收尾.
private BluetoothGattCallback gattCallback = new BluetoothGattCallback() {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
switch (newState) {
case BluetoothProfile.STATE_CONNECTED:
Log.d("BLED-GATT", "STATE_CONNECTED");
setUIConnectionStatus("Discover services on device...", Color.YELLOW);
checkEnableAddButton(simpleTrackEditText.getText().toString());
gatt.discoverServices();
break;
case BluetoothProfile.STATE_DISCONNECTED:
Log.d("BLED-GATT", "STATE_DISCONNECTED");
setUIConnectionStatus("Not Connected!", Color.RED);
gatt.close();
break;
default:
Log.d("BLED-GATT", "STATE_OTHER");
}
}
}
Run Code Online (Sandbox Code Playgroud)
执行此操作后,我无法再在呼叫后控制设备disconnectDevice()
.设备本身似乎认为它仍然连接,因为我无法将其置于广播可见性模式(如果它已经有连接就会发生).但是,如果我终止应用程序并再次打开它,那么我可以将设备设置为广播模式.这告诉我应用程序未正确断开连接.
知道我错过了什么吗?
我有一个按钮说myButton
。我想以编程方式设置按钮的左上角半径。我正在寻找类似的东西
myButton.setTopLeftCornerRadius(10);
Run Code Online (Sandbox Code Playgroud)
我在 eclipse 中寻找了一种像“setcornerradius”这样的方法,但一无所获。
即使我多次更新 LiveData,我的 BindingAdapter 也只运行一次。
public class ButtonViewBindingAdapter
{
@BindingAdapter("hideIfZero")
public static void setHideIfZero(View view, MutableLiveData<Integer> currentPosition)
{
view.setVisibility(currentPosition.getValue() == 0 ? View.GONE : View.VISIBLE);
}
}
Run Code Online (Sandbox Code Playgroud)
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="viewModel"
type="com.package.PermissionsViewModel"/>
<variable
name="clickHandler"
type="com.package.PermissionsActivity.ClickHandler"/>
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/buttonNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:background="@null"
android:onClick="@{() -> clickHandler.nextSlide()}"
android:text="@string/intro_next"
android:textColor="@android:color/white"
/>
<Button
android:id="@+id/buttonBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:background="@null"
android:onClick="@{() -> clickHandler.previousSlide()}"
android:text="@string/intro_back"
android:textColor="@android:color/white"
app:hideIfZero="@{viewModel.currentSlidePosition}"/>
</RelativeLayout>
</layout>
Run Code Online (Sandbox Code Playgroud)
public class PermissionsViewModel extends ViewModel
{
private MutableLiveData<Integer> currentSlidePosition = new MutableLiveData<>(); …
Run Code Online (Sandbox Code Playgroud) 我是嵌入式数据库的新手,但我至少运行它.令我困惑的是我的数据没有在运行之间保存.我的意思是测试不是很好吗?每次运行应用程序时,我都不想将数据添加到我的数据库中
所以我搜索了一种方法来做到这一点,我发现我将配置一个hibernate连接URL,我尝试这样做
props.put("hibernate.connection.url", "jdbc:h2:~/test");
Run Code Online (Sandbox Code Playgroud)
在我的HibernateConfiguration.java中.虽然没有成功,但没有错误但也没有保存,我没有找到应该从该URL创建的测试文件.(运行Windows并检查我的用户文件夹)
我也看到它可以像这样做
<jdbc:embedded-database id="dataSource" type="H2">
<jdbc:script location="classpath:db-schema.sql"/>
<jdbc:script location="classpath:db-test-data.sql"/>
</jdbc:embedded-database>
Run Code Online (Sandbox Code Playgroud)
并且每次运行应用程序时都执行脚本,但问题是我希望hibernate处理所有表的创建等.
这通常是怎么做的?
我现在搜索了几个小时,但还没有得到它.
PS.如果需要我会发布我的所有配置.
编辑: 更新了我的问题以包含对一个问题的关注并包括我的配置.
HibernateConfiguration.java包com.courseinfo.project;
import java.util.Properties;
import javax.sql.DataSource;
import org.hibernate.dialect.H2Dialect;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.hibernate3.HibernateTransactionManager;
import org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean;
import com.courseinfo.project.model.Course;
@Configuration
public class HibernateConfiguration {
@Value("#{dataSource}")
private DataSource dataSource;
@Bean
public AnnotationSessionFactoryBean sessionFactoryBean() {
Properties props = new Properties();
props.put("hibernate.dialect", H2Dialect.class.getName());
props.put("hibernate.format_sql", "true");
props.put("hibernate.connection.url", "jdbc:h2:~/test");
AnnotationSessionFactoryBean bean = new AnnotationSessionFactoryBean();
bean.setAnnotatedClasses(new Class[]{Course.class});
bean.setHibernateProperties(props);
bean.setDataSource(this.dataSource);
bean.setSchemaUpdate(true);
return bean;
}
@Bean
public HibernateTransactionManager …
Run Code Online (Sandbox Code Playgroud)