我开发一个应用程序,并节省一些字符串一样postedAtTime,postedBy,postedOnDate在火力地堡数据库.我想将GeoFire坐标保存在保存所有上述字符串的同一节点中,以便稍后我可以轻松地进行查询.
这是我保存所有字符串的路径:
databaseReferenceHRequests = firebaseDatabase.getReferenceFromUrl("https://appName-e1a35.firebaseio.com/requests/");
Run Code Online (Sandbox Code Playgroud)
这是我如何保存它:
// in onButtonClicked method:
postNewRequest(null, imageUID, MainActivity.userName.getText().toString(), time, date, utcFormatDateTime, MainActivity.userEmail.getText().toString(), geoFire);
// the method:
public void postNewRequest(Bitmap bitmap, String imageUIDh, String postedBy, String postedAtTime, String postedOnDate, String utcFormatDateTime, String userEmail, GeoFire geoFire) {
HRequest hRequest = new HelpRequest(null, imageUIDh, postedBy, postedAtTime, postedOnDate, utcFormatDateTime, userEmail, geoFire);
databaseReferenceHRequests.push().setValue(hRequest);
}
Run Code Online (Sandbox Code Playgroud)
以下是它如何保存在数据库中:
我想要的是将GeoFire坐标保存在同一个节点中,就-KLIoLUsI0SpQZGpV1h4在这里.这只是一个推送ID,它随机生成.
我试过这个参考:
geoFire = new GeoFire(firebaseDatabase.getReferenceFromUrl("https://appName-e1a35.firebaseio.com/requests/"));
Run Code Online (Sandbox Code Playgroud)
然后用上面显示的其他项目推送它.但是,这只保存了GeoFire坐标而不保存节点下的其他项目requests.
那么,我的GeoFire参考应该是什么,以便它与同一节点中的所有数据一起保存?
这里出了什么问题?请告诉我.
我有一个SettingsActivity扩展PreferenceActivity到我的应用程序中显示设置.
有一个后退箭头,但它不起作用.
这是SettingsActivity.java文件的代码:
public class SettingsActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener{
private AppCompatDelegate mDelegate;
public static final String RESET_PASSWORD_KEY = "reset_password";
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
getDelegate().installViewFactory();
getDelegate().onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
SharedPreferences sharedPreferencesCompat = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
Preference myPref = (Preference) findPreference(RESET_PASSWORD_KEY);
myPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
//open browser or intent here
Intent resetPasswordActivityIntent = new Intent(SettingsActivity.this, ResetPasswordActivity.class);
startActivity(resetPasswordActivityIntent);
return true;
}
});
}
@Override
protected void onPostCreate(Bundle savedInstanceState) …Run Code Online (Sandbox Code Playgroud) android preferenceactivity android-preferences android-sharedpreferences
我在我的应用中提供了GoogleSignIn选项.
这是我的代码:
public class SignupActivity extends AppCompatActivity {
private static final int RC_SIGN_IN = 1;
GoogleApiClient mGoogleApiClient;
FirebaseAuth mAuth;
TextView appName;
ProgressDialog signinProgressDialog;
CoordinatorLayout coordinatorLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);
// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
signinProgressDialog = new ProgressDialog(SignupActivity.this);
coordinatorLayout = (CoordinatorLayout) findViewById(R.id.signupCoordinatorLayout);
// Configure Google Sign In
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.o_auth_client_id))
.requestEmail()
.requestProfile()
.requestId()
.build();
// Build a GoogleApiClient with access to the Google Sign-In API and the
// options specified …Run Code Online (Sandbox Code Playgroud) android google-api-client firebase firebase-authentication google-signin
我试图把里面的一些代码AlertDialog.Builder的builder.setPositiveButton方法.
问题是我收到以下错误: Cannot resolve method 'addOnCompletionListener(anonymous android.content.DialogInterface.OnClickListener, anonymous com.google.android.gms.tasks.OnCompletionListener<com.google.firebase.auth.AuthResult>)
这是代码:
AlertDialog.Builder builder = new AlertDialog.Builder(SignUpActivity.this);
builder.setTitle("Title");
builder.setView(R.layout.customlayout);
builder.setPositiveButton("Continue", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
//error from below line
mAuth.createUserWithEmailAndPassword(userEmail.getText().toString(), userPassword.getText().toString())
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Log.d("signUpSuccessful", "createUserWithEmail:onComplete:" + task.isSuccessful());
// If sign in fails, display a message to the user. If sign in succeeds
// the auth state listener will be notified and logic to …Run Code Online (Sandbox Code Playgroud) android android-alertdialog firebase firebase-authentication
我正在开发一个Android应用程序,其中我在'FirebaseDatabase`上存储两种不同类型的信息.
然后在MainActivity,我正在检索它们并向用户显示RecyclerView.这两个信息都是以不同的布局显示的,即两者的布局都不同,这就是为什么我有两个不同的Model类,现在有两个不同的适配器.我正在使用@MikePenz的FastAdapter
所以,我做的是我在recyclerview上设置适配器的顺序与从数据库中获取信息的顺序相同:
1.
public void prepareDataOfSRequests() {
gModelClass = new GModelClass(postedBy, ***, ***, ***, "error", ***, formattedTime, currentLatitude, currentLongitude, utcFormatDateTime, userEmail, userID, null, ***, itemID);
fastItemAdapter.add(0, gModelClass);
recyclerView.setAdapter(fastItemAdapter);
recyclerView.smoothScrollToPosition(0);
emptyRVtext.setVisibility(View.INVISIBLE);
}
Run Code Online (Sandbox Code Playgroud)
2.
public void prepareDataOfERequests() {
eModelClass = new EModelClass(***, ***, ***, ***, "error", ***, formattedTimeE, currentLatitudeE, currentLongitudeE, utcFormatDateTimeE, userEmailE, userIDE, null, ***, ***, ***, ***, itemID);
fastItemAdapterER.add(eventRequestsModelClass);
recyclerView.setAdapter(fastItemAdapterER);
recyclerView.smoothScrollToPosition(0);
emptyRVtext.setVisibility(View.INVISIBLE);
}
Run Code Online (Sandbox Code Playgroud)
由于recyclerview只有一个,我正在逐个设置2个不同的适配器,所以Recyclerview正在使用第二个适配器进行更新并仅显示其内容.
那么,如何将适配器显示或设置为相同的"RecyclerView"并显示存储在两个适配器中的内容.
android android-adapter android-viewholder android-recyclerview fastadapter
我String从数据库中获取3个值,然后我将其转换为Long然后我正在计算差异,然后将此计算Long值作为参数放入方法中.我正在使用FastAdapter.
这filterRequests(List <Long> l)是一种MainActivity基于long来过滤请求/内容的逻辑的方法l.
整个适配器:
public class GRModelClass extends AbstractItem<GRModelClass, GRClass.ViewHolder>{
private static final ViewHolderFactory<? extends ViewHolder> FACTORY = new ItemFactory();
String postedBy, postedTime, currentLat, currentLng, utcFormatDateTime, userEmail, userID;
String startDateTimeInEpoch, endDateTimeInEpoch;
DatabaseReference primaryDBKey;
long ms;
String itemID;
public GRModelClass(){}
public GRModelClass(String postedBy, String postedTime, String currentLat, String currentLng, String utcFormatDateTime, String userEmail, String userID, String startDateTimeInEpoch, String endDateTimeInEpoch, DatabaseReference primaryDBKey) {
this.postedBy = " " …Run Code Online (Sandbox Code Playgroud) 我正在开发一个Android应用程序.
点击按钮后,会生成一个深层链接并与朋友分享.
问题是,点击共享的深层链接后,即使安装了应用程序,Play商店也会打开.
我按照这个文档.
这是intent-filter:
<!-- [START link_intent_filter] -->
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="example.com" android:scheme="http"/>
<data android:host="example.com" android:scheme="https"/>
</intent-filter>
<!-- [END link_intent_filter] -->
Run Code Online (Sandbox Code Playgroud)
这是我如何创建网址(手动):
Uri BASE_URI = Uri.parse("https://domainname.com/");
packageName = getBaseContext().getPackageName();
APP_URI = BASE_URI.buildUpon().path(requestID.getText().toString().trim())
.appendQueryParameter("query1", query1.getText().toString())
.appendQueryParameter("query2", query2.getText().toString())
.appendQueryParameter("query3", query3.getText().toString()).build();
try {
String encodedUri = URLEncoder.encode(APP_URI.toString(), "UTF-8");
deepLink = Uri.parse("https://myappcode.app.goo.gl/?link="+encodedUri+"&apn="+holder.packageName+"&amv="+16+"&ad="+0);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
这是收到的深层链接/网址: http://domainname.com/-KcldzAeJHrPS5tnfxTk?query1=query1&query2=query2&query3=query3
这可能有什么问题?
我有以下作为AppCompatSpinner条目:
<string-array name="startTimeList">
<item>Now</item>
<item>Pick a time..</item>
</string-array>
Run Code Online (Sandbox Code Playgroud)
选择后Pick a time..,TimePickerDialog打开a并允许用户选择时间.这是如何做:
startTimeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
// startTimeString = adapterView.getItemAtPosition(i).toString();
DateFormat currentDateFormat = new SimpleDateFormat("HH:mm:ss");
userAvailableTimeInSF = currentDateFormat.format(new Date());
final TextView startTimeSpinnerTV = (TextView) adapterView.getSelectedView();
startTimeSpinnerTV.setText(userAvailableTimeInSF);
switch (i) {
case 0:
userAvailableTimeInSF = currentDateFormat.format(new Date());
startTimeSpinnerTV.setText("Now");
break;
default:
final Calendar c = Calendar.getInstance();
mHour = c.get(Calendar.HOUR_OF_DAY);
mMinute = c.get(Calendar.MINUTE);
TimePickerDialog timePickerDialog = new TimePickerDialog(PostSportRequest.this, …Run Code Online (Sandbox Code Playgroud) 我有几个项目,RecyclerView每个项目都有一个long保存的值.我正在使用FastAdapter作为我的适配器RecyclerView.
假设有在7个项目RecyclerView与长值:11122,12321,-98811,8870,-88009,3398,和-22113.
所以,我想要做的是,我想使用这个逻辑基于上面给出的长值过滤项目:
if (l <= 1000) {
// show items with long value <=1000
} else if (l > 1000) {
// show items with long value >1000
}
Run Code Online (Sandbox Code Playgroud)
我尝试了各种各样的东西,但没有成功.
更新1:这里的项目是一种存储在CardView其中然后显示的不同数据RecyclerView.每张卡包含不同的数据,其中一个是上面给出的long值.我想long根据上面给出的逻辑,根据存储在每张卡中的这些值来过滤数据.
请帮助我解决这个问题,并提出一些我可以实现此目的的算法或代码.
我正在开发一个应用程序,我已经做了以下显示的布局:
有一个CircleImageView和一个CardView.
这是XML代码:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.playrapp.playr.Profile"
tools:showIn="@layout/activity_profile">
<android.support.v7.widget.CardView
android:id="@+id/profileCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
app:contentPadding="10dp">
</android.support.v7.widget.CardView>
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/userImageProfile"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginTop="50dp"
android:src="@mipmap/ic_launcher"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
在这里,cardview在imageview上.我希望imageview能够超越cardview.我怎样才能做到这一点?
请告诉我.
android android-layout android-xml android-imageview android-cardview
android ×10
firebase ×4
java ×3
fastadapter ×2
algorithm ×1
android-xml ×1
geofire ×1
instanceof ×1
intentfilter ×1
methods ×1
timepicker ×1