因此,我的任务是使用Parse在应用程序(iOS,Swift)中实现类似"转推"的功能.
这是在此之前被问到的,但这是a)非常高级别的b)我得到了手头的任务 - 我不一定在建筑决策上寻求帮助,但如果看起来我显然错过了什么,我'我乐意接受反馈.
我的应用程序有CAUSES,每个都由USER创建.还有一个带有TO和FROM用户的FOLLOW表.首先,我只是查询CAUSES表,其中发布的USER应该与FOLLOW表中TO用户的objectId(当前用户是FROM用户)匹配.更简洁:
let getFollowedUsersQuery = PFQuery(className: Constants.kParseClassFollowers)
getFollowedUsersQuery.whereKey(Constants.kParseFieldFromUser, equalTo: PFUser.currentUser()!)
let causesQuery = PFQuery(className: Constants.kParseClassCauses)
causesQuery.whereKey(Constants.kParseFieldFromUser, matchesKey: Constants.kParseFieldToUser, inQuery: getFollowedUsersQuery)
causesQuery.findObjectsInBackgroundWithBlock({ (objects, error) -> Void in
if let causes = objects {
for cause in causes {
// populate the tableview cells, etc.
}
}
})
Run Code Online (Sandbox Code Playgroud)
现在我有来自用户的所有原因,我遵循...这都是非常标准的.
这是它变得棘手的地方.
每个CAUSE也有一个名为SUPPORTERS的Relation.现在我需要构建一种方法来从我不遵循的人那里获得所有CAUSES,但是在他们的支持者列表中有我关注的用户.
我还没有找到一个优雅的解决方案,虽然我正在接近一个"蛮力"的解决方案,它是如此繁琐和冗长,以至于我的程序员大脑中更好的一半像Susan Powter一样尖叫着 ......
这是一个示例:
let retweetQuery = PFQuery(className: Constants.kParseClassCauses)
retweetQuery.orderByDescending(Constants.kParseFieldCreatedAt)
retweetQuery.whereKey(Constants.kParseFieldFromUser, notEqualTo: PFUser.currentUser()!)
retweetQuery.whereKey(Constants.kParseFieldFromUser, doesNotMatchKey: Constants.kParseFieldToUser, inQuery: getFollowedUsersQuery)
retweetQuery.findObjectsInBackgroundWithBlock({ …
Run Code Online (Sandbox Code Playgroud) 我使用了一些传感器 - MediaRecorder和MediaPlayer,NotificationManager,WakeLock和LocationListener ......
这是我的onResume()和onPause()函数:
void onResume() {
super.onResume();
//GPS Sensor
locationListener = new MyLocationListener();
locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 0, 0, locationListener);
// Notification Manager
gNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
gNotification = new Notification();
gNotification.vibrate = gVibrate;
}
Run Code Online (Sandbox Code Playgroud)
...
void onPause() {
super.onPause();
// Release the Recorder
if (mRecorder != null) {
mRecorder.release();
mRecorder = null;
}
// Release the Media Player
if(mPlayer != null) {
mPlayer.release();
mPlayer = null;
}
// Release Power Manager
wake.Stop();
wake = null;
// …
Run Code Online (Sandbox Code Playgroud) 即使在添加依赖项并导入类之后,我也会收到java.lang.NoClassDefFoundError:com.squareup.okhttp.logging.HttpLoggingInterceptor.
有人可以帮忙吗?
Gradle构建文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "xyz"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
mavenCentral()
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.google.code.gson:gson:2.4'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.okhttp:logging-interceptor:2.6.0'
}
Run Code Online (Sandbox Code Playgroud) 好的,所以我正在尝试实现一个包含三个页面的 ViewPager,并且每个页面都有独特的内容,所以我建立了一个系统,我根据页面索引膨胀不同的布局。这在我导航后立即起作用,但我注意到 Fragment 被调用了两次。
这是我的 FragmentAcivity 类:
public class TutorialScreen extends FragmentActivity {
private static final String TAG = "TAG";
private static final int NUM_PAGES = 3;
private ViewPager pager; // animation handler
private PagerAdapter adapter; // provides pages to pager
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tutorial_layout);
// Instantiate Pager & Adapter
pager = (ViewPager) findViewById(R.id.pager);
adapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
pager.setAdapter(adapter);
Log.v(TAG, "Initial Page is " + pager.getCurrentItem()); // this logs '0' - which is what i want …
Run Code Online (Sandbox Code Playgroud) 我正在尝试开发一个小型库来将问题发布到我公司的 Jira 服务器,并且我认为带有KTOR的 Kotlin MPP就可以解决问题。
起初,按照一些教程,我创建了一个共享项目,iOS 的导入工作正常,但 Android 的 Ktor 实现无法解决。然后我意识到我需要重新创建项目并创建一个库而不是共享应用程序,因为我已经为每个移动客户端提供了现有的代码库,并且我需要发布 MPP 库以供它们使用。
将项目重新创建为库并开始添加KTOR 1.3.2的依赖项后,iOS 依赖项无法解析。这不仅仅是 KTOR,它是任何 iOS 依赖项,所以我的项目设置中显然有一些不正确的地方,但我无法发现它。
这是 gradle 文件:
plugins {
id 'org.jetbrains.kotlin.multiplatform' version '1.3.72'
}
repositories {
jcenter()
mavenCentral()
maven { url "https://kotlin.bintray.com/kotlinx" }
}
group 'com.example.issuereporter'
version '0.0.1'
apply plugin: 'maven-publish'
kotlin {
targets {
final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") ? presets.iosArm64 : presets.iosX64
fromPreset(iOSTarget, 'ios') {
binaries {
framework('IssueReporter')
}
}
fromPreset(presets.jvm, 'android')
}
def ktor_version = "1.3.2"
sourceSets["commonMain"].dependencies { …
Run Code Online (Sandbox Code Playgroud) 我有一个 Parse 类,它有一个指向另一个类的指针......我想计算 A 类中具有特定值的对象,该值等于 B 类中的一个字段......
例如。
ParseQuery<ParseObject> query = ParseQuery.getQuery("ClassA");
query.whereEqualTo(ClassB.field, mValToCheck); // ?!??!?
query.countInBackground(new CountCallback() {
// etc
Run Code Online (Sandbox Code Playgroud)
我难住了。想法?
((我也在 Unity Answers 和 GameDev 上发布了此内容,但在此发布 x-posting 以防任何 C# 网络负责人可以指出我的 HttpWebRequest 代码中的任何明显错误...))
我正在尝试通过他们的 SDK 将通过我的游戏捕获的图像发布到 Facebook,并且由于它需要一个 URI,我编写了一个简单的 AWS Lambda 函数来获取一个字节数组并将其上传到 AWS 存储桶。AWS 函数接受一个调用,然后返回一个 URL 以使用图像数据调用 PUT ......所以这个想法是,如果响应是 200,使用该 URL 发布到 FB。
但是 - 使用 Unity 5.2.x 到 5.3.4 和 Android 4.4 - 6.1 - 它总是给我 403 响应,同时在 iOS 上工作正常。
所以,我有一个接受 byte[] 的方法,然后执行以下操作:
WWW w = new WWW("https://my-amazon-function-to-call");
yield return w;
if (!string.IsNullOrEmpty(w.error)) {
Debug.LogError(w.error);
}
else
{
var dict = Json.Deserialize(w.text) as Dictionary<string,object>;
string oneTimeUploadUrl = (string)dict["oneTimeUploadUrl"]; // …
Run Code Online (Sandbox Code Playgroud) Kotlin 协程问题...正在努力使用属性而不是函数作为异步调用的访问器。
背景是我正在尝试将FusedLocationProviderClient
与kotlinx-coroutines-play-services
库一起使用,以便使用该.await()
方法Task
而不是添加回调......
目前有一个属性 getter 被踢出挂起函数,但不确定如何正确启动协程以避免
找到所需单位 XYZ
错误...
val lastUserLatLng: LatLng?
get() {
val location = lastUserLocation
return if (location != null) {
LatLng(location.latitude, location.longitude)
} else {
null
}
}
val lastUserLocation: Location?
get() {
GlobalScope.launch {
return@launch getLastUserLocationAsync() <--- ERROR HERE
}
}
private suspend fun getLastUserLocationAsync() : Location? = withContext(Dispatchers.Main) {
return@withContext if (enabled) fusedLocationClient.lastLocation.await() else null
}
Run Code Online (Sandbox Code Playgroud)
关于如何处理这个问题有什么想法吗?