java - 使用日期来管理订阅。安卓。火力基地
问题描述
我的问题是这个活动。我想获取时间,将其与数据库上的时间进行比较,然后如果订阅尚未过期,则显示一个按钮,如果它已隐藏它。另外,我想在顶部显示用户的信用,以及图像和他的名字。我尝试了很多东西,但由于某种原因它一直在崩溃。
public void getthedate(){
calendar = Calendar.getInstance();
final SimpleDateFormat mdformat = new SimpleDateFormat("yyyy / MM / dd ");
// strDate = "Current Date : " + mdformat.format(calendar.getTime());
// futurecal = Calendar.getInstance();
// futurecal.add(Calendar.DATE, 30);
// futuredate = mdformat.format(futurecal.getTime());
DatabaseReference subtime = mDatabase.child("users").child(univ).child(uid);
subtime.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
subtimedate = dataSnapshot.child("subdate").getValue().toString();
String username = dataSnapshot.child("Full name").getValue().toString();
String coinstring = dataSnapshot.child("coins").getValue().toString();
coinview.setText(coinstring);
String imglink = dataSnapshot.child("imageuri").getValue().toString();
Glide.with(c).load(imglink).into(userthing);
hellostring.setText("Hey" + username + "!");
Date subdatecal = null;
try {
subdatecal = mdformat.parse(subtimedate);
} catch (ParseException e) {
e.printStackTrace();
}
Calendar newestcal = Calendar.getInstance();
newestcal.setTime(subdatecal);
if (newestcal.after(mdformat.format(calendar.getTime()))){
substat.setText("Active");
substat.setBackgroundColor(Color.GREEN);
//do something if subscription hasnt expired
}else{
gotonotes.setVisibility(View.GONE);
substat.setText("Expired");
substat.setBackgroundColor(Color.RED);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
/*
DatabaseReference subtime = mDatabase.child("users").child(univ).child(uid).child("subdate");
subtime.setValue(futuredate);
set new subscription
*/
/* if (calendar.after(futurecal)){
use this to check if date has passed
}*/
}
在 oncreate 我已经设置了一切。
substat = (TextView) findViewById(R.id.substat);
hellostring = (TextView) findViewById(R.id.hellostring);
coinview = (TextView) findViewById(R.id.coinview);
userthing = (ImageView) findViewById(R.id.userimagething);
mDatabase = FirebaseDatabase.getInstance().getReference();
friendbtn = (Button) findViewById(R.id.friendsbtn);
uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
感谢您的任何建议!
这是活动崩溃时我在 android studio 上的手机上的 logcat
10-22 19:00:46.363 20227-20227/? I/art: Late-enabling -Xcheck:jni
10-22 19:00:46.473 20227-20227/com.studybuddy.mixal.android W/System: ClassLoader referenced unknown path: /data/app/com.studybuddy.mixal.android-2/lib/arm64
10-22 19:00:46.592 20227-20227/com.studybuddy.mixal.android I/FirebaseInitProvider: FirebaseApp initialization successful
10-22 19:00:46.635 20227-20227/com.studybuddy.mixal.android W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
10-22 19:00:46.639 20227-20261/com.studybuddy.mixal.android I/FA: App measurement is starting up, version: 12780
To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.studybuddy.mixal.android
10-22 19:00:46.703 20227-20261/com.studybuddy.mixal.android I/FA: Tag Manager is not found and thus will not be used
10-22 19:00:46.705 20227-20227/com.studybuddy.mixal.android I/HwSecImmHelper: mSecurityInputMethodService is null
10-22 19:00:46.718 20227-20227/com.studybuddy.mixal.android E/HAL: load: id=gralloc != hmi->id=gralloc
10-22 19:00:46.899 20227-20284/com.studybuddy.mixal.android I/DynamiteModule: Considering local module com.google.android.gms.firebase_database:4 and remote module com.google.android.gms.firebase_database:6
Selected remote version of com.google.android.gms.firebase_database, version >= 6
10-22 19:00:46.949 20227-20284/com.studybuddy.mixal.android W/System: ClassLoader referenced unknown path: /data/data/com.google.android.gms/app_chimera/m/00000086/n/arm64-v8a
10-22 19:00:46.960 20227-20272/com.studybuddy.mixal.android E/HAL: load: id=gralloc != hmi->id=gralloc
10-22 19:00:46.961 20227-20272/com.studybuddy.mixal.android I/OpenGLRenderer: Initialized EGL, version 1.4
10-22 19:00:46.971 20227-20272/com.studybuddy.mixal.android W/OpenGLRenderer: load: so=/system/lib64/libhwuibp.so
dlopen failed: library "/system/lib64/libhwuibp.so" not found
Initialize Binary Program Cache: Load Failed
10-22 19:00:46.971 20227-20272/com.studybuddy.mixal.android E/HAL: load: id=gralloc != hmi->id=gralloc
10-22 19:00:47.058 20227-20299/com.studybuddy.mixal.android I/System: core_booster, getBoosterConfig = false
10-22 19:00:48.781 20227-20227/com.studybuddy.mixal.android I/Process: Sending signal. PID: 20227 SIG: 9
解决方案
推荐阅读
- node.js - Discord JS - TypeError:无法读取未定义的属性“setChannel”
- apache-spark - Pyspark - 根据单词列表检查列字符串并删除
- javascript - 为什么自动检测 otp 没有在 React 中渲染代码
- android - 如何在没有 Partial_Wakelock 的情况下让我的应用程序也以打盹模式运行?
- c++ - 多线程管理器
- php - 如何正确关闭 OOP PHP 数据库连接?
- bash - 使用 awk 命令的 bash 脚本中的语法错误
- asp.net-core - 无法使用 Ubuntu 20.04 使 Net5 工作(OpenSSL 连接问题)
- matlab-figure - 在matlab中手动进行卷积
- spring - Spring Data Cassandra 不处理原始 UDTS,不抛出合适的转换器异常