[WIP] gradle builds but app freezes, updated fbjni so file is the possible culprit
This commit is contained in:
@@ -45,19 +45,19 @@ dependencies {
|
||||
androidTestImplementation deps.supportTestRunner
|
||||
androidTestImplementation deps.supportEspresso
|
||||
// Litho
|
||||
// implementation deps.lithoCore
|
||||
// implementation deps.lithoWidget
|
||||
// compileOnly deps.lithoAnnotations
|
||||
implementation deps.lithoCore
|
||||
implementation deps.lithoWidget
|
||||
compileOnly deps.lithoAnnotations
|
||||
|
||||
// annotationProcessor deps.lithoProcessor
|
||||
annotationProcessor deps.lithoProcessor
|
||||
|
||||
// SoLoader
|
||||
implementation deps.soloader
|
||||
|
||||
// For integration with Fresco
|
||||
// implementation deps.lithoFresco
|
||||
implementation deps.lithoFresco
|
||||
// For testing
|
||||
// testImplementation deps.lithoTesting
|
||||
testImplementation deps.lithoTesting
|
||||
|
||||
implementation deps.okhttp3
|
||||
implementation project(':android')
|
||||
|
||||
@@ -8,8 +8,8 @@ import java.util.List;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
// import com.facebook.litho.ComponentContext;
|
||||
// import com.facebook.litho.LithoView;
|
||||
import com.facebook.litho.ComponentContext;
|
||||
import com.facebook.litho.LithoView;
|
||||
import android.util.Log;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
@@ -17,21 +17,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Log.d("ON CREATE SAMPLE APP", "I m in Oncreate of sample app");
|
||||
// final ComponentContext c = new ComponentContext(this);
|
||||
// setContentView(
|
||||
// LithoView.create(
|
||||
// c,
|
||||
// RootComponent.create(c).build()));
|
||||
LinearLayout linearLayout = new LinearLayout(this);
|
||||
TextView ProgrammaticallyTextView = new TextView(this);
|
||||
ProgrammaticallyTextView.setText("Hello World");
|
||||
ProgrammaticallyTextView.setTextSize(22);
|
||||
ProgrammaticallyTextView.setPadding(20, 300, 20, 100);
|
||||
|
||||
linearLayout.addView(ProgrammaticallyTextView);
|
||||
|
||||
setContentView(linearLayout, new LinearLayout.LayoutParams(
|
||||
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
||||
final ComponentContext c = new ComponentContext(this);
|
||||
setContentView(
|
||||
LithoView.create(
|
||||
c,
|
||||
RootComponent.create(c).build()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,105 +1,105 @@
|
||||
// // Copyright 2004-present Facebook. All Rights Reserved.
|
||||
//
|
||||
// package com.facebook.sonar.sample;
|
||||
//
|
||||
// import com.facebook.litho.Column;
|
||||
// import com.facebook.litho.Component;
|
||||
// import com.facebook.litho.ComponentContext;
|
||||
// import com.facebook.litho.annotations.LayoutSpec;
|
||||
// import com.facebook.litho.annotations.OnCreateLayout;
|
||||
// import com.facebook.litho.widget.Text;
|
||||
// import okhttp3.Request;
|
||||
// import okhttp3.Response;
|
||||
// import okhttp3.RequestBody;
|
||||
// import okhttp3.FormBody;
|
||||
// import okhttp3.FormBody.Builder;
|
||||
// import okhttp3.OkHttpClient;
|
||||
// import okhttp3.Call;
|
||||
// import okhttp3.Callback;
|
||||
// import com.facebook.litho.ClickEvent;
|
||||
// import android.util.Log;
|
||||
// import java.io.IOException;
|
||||
// import com.facebook.litho.annotations.OnEvent;
|
||||
//
|
||||
// @LayoutSpec
|
||||
// public class RootComponentSpec {
|
||||
//
|
||||
// @OnCreateLayout
|
||||
// static Component onCreateLayout(ComponentContext c) {
|
||||
// return Column.create(c)
|
||||
// .child(
|
||||
// Text.create(c)
|
||||
// .text("Tap to hit get request")
|
||||
// .key("1")
|
||||
// .textSizeSp(20)
|
||||
// .clickHandler(RootComponent.hitGetRequest(c)))
|
||||
// .child(
|
||||
// Text.create(c)
|
||||
// .text("Tap to hit post request")
|
||||
// .key("2")
|
||||
// .textSizeSp(20)
|
||||
// .clickHandler(RootComponent.hitPostRequest(c)))
|
||||
// .child(
|
||||
// Text.create(c)
|
||||
// .text("I m just a text")
|
||||
// .key("3")
|
||||
// .textSizeSp(20))
|
||||
// .build();
|
||||
// }
|
||||
//
|
||||
// @OnEvent(ClickEvent.class)
|
||||
// static void hitGetRequest(ComponentContext c) {
|
||||
//
|
||||
// Request request = new Request.Builder()
|
||||
// .url("https://api.github.com/repos/facebook/yoga")
|
||||
// .get()
|
||||
// .build();
|
||||
// SonarSampleApplication.okhttpClient.newCall(request).enqueue(new Callback() {
|
||||
// @Override
|
||||
// public void onFailure(Call call, IOException e) {
|
||||
// e.printStackTrace();
|
||||
// Log.d("Sonar", e.getMessage());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onResponse(Call call, Response response) throws IOException {
|
||||
// if (response.isSuccessful()) {
|
||||
// Log.d("Sonar", response.body().string());
|
||||
// } else {
|
||||
// Log.d("Sonar", "not successful");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// @OnEvent(ClickEvent.class)
|
||||
// static void hitPostRequest(ComponentContext c) {
|
||||
//
|
||||
// RequestBody formBody = new FormBody.Builder()
|
||||
// .add("app", "Sonar")
|
||||
// .add("remarks", "Its awesome")
|
||||
// .build();
|
||||
//
|
||||
// Request request = new Request.Builder()
|
||||
// .url("https://demo9512366.mockable.io/SonarPost")
|
||||
// .post(formBody)
|
||||
// .build();
|
||||
//
|
||||
// SonarSampleApplication.okhttpClient.newCall(request).enqueue(new Callback() {
|
||||
// @Override
|
||||
// public void onFailure(Call call, IOException e) {
|
||||
// e.printStackTrace();
|
||||
// Log.d("Sonar", e.getMessage());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onResponse(Call call, Response response) throws IOException {
|
||||
// if (response.isSuccessful()) {
|
||||
// Log.d("Sonar", response.body().string());
|
||||
// } else {
|
||||
// Log.d("Sonar", "not successful");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||
|
||||
package com.facebook.sonar.sample;
|
||||
|
||||
import com.facebook.litho.Column;
|
||||
import com.facebook.litho.Component;
|
||||
import com.facebook.litho.ComponentContext;
|
||||
import com.facebook.litho.annotations.LayoutSpec;
|
||||
import com.facebook.litho.annotations.OnCreateLayout;
|
||||
import com.facebook.litho.widget.Text;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.FormBody;
|
||||
import okhttp3.FormBody.Builder;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import com.facebook.litho.ClickEvent;
|
||||
import android.util.Log;
|
||||
import java.io.IOException;
|
||||
import com.facebook.litho.annotations.OnEvent;
|
||||
|
||||
@LayoutSpec
|
||||
public class RootComponentSpec {
|
||||
|
||||
@OnCreateLayout
|
||||
static Component onCreateLayout(ComponentContext c) {
|
||||
return Column.create(c)
|
||||
.child(
|
||||
Text.create(c)
|
||||
.text("Tap to hit get request")
|
||||
.key("1")
|
||||
.textSizeSp(20)
|
||||
.clickHandler(RootComponent.hitGetRequest(c)))
|
||||
.child(
|
||||
Text.create(c)
|
||||
.text("Tap to hit post request")
|
||||
.key("2")
|
||||
.textSizeSp(20)
|
||||
.clickHandler(RootComponent.hitPostRequest(c)))
|
||||
.child(
|
||||
Text.create(c)
|
||||
.text("I m just a text")
|
||||
.key("3")
|
||||
.textSizeSp(20))
|
||||
.build();
|
||||
}
|
||||
|
||||
@OnEvent(ClickEvent.class)
|
||||
static void hitGetRequest(ComponentContext c) {
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url("https://api.github.com/repos/facebook/yoga")
|
||||
.get()
|
||||
.build();
|
||||
SonarSampleApplication.okhttpClient.newCall(request).enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.d("Sonar", e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
if (response.isSuccessful()) {
|
||||
Log.d("Sonar", response.body().string());
|
||||
} else {
|
||||
Log.d("Sonar", "not successful");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@OnEvent(ClickEvent.class)
|
||||
static void hitPostRequest(ComponentContext c) {
|
||||
|
||||
RequestBody formBody = new FormBody.Builder()
|
||||
.add("app", "Sonar")
|
||||
.add("remarks", "Its awesome")
|
||||
.build();
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url("https://demo9512366.mockable.io/SonarPost")
|
||||
.post(formBody)
|
||||
.build();
|
||||
|
||||
SonarSampleApplication.okhttpClient.newCall(request).enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.d("Sonar", e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
if (response.isSuccessful()) {
|
||||
Log.d("Sonar", response.body().string());
|
||||
} else {
|
||||
Log.d("Sonar", "not successful");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,54 +10,46 @@ import java.util.List;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
// import com.facebook.litho.sonar.LithoSonarDescriptors;
|
||||
import com.facebook.litho.sonar.LithoSonarDescriptors;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
import com.facebook.sonar.plugins.inspector.DescriptorMapping;
|
||||
import com.facebook.sonar.plugins.inspector.InspectorSonarPlugin;
|
||||
// import com.facebook.sonar.android.utils.SonarUtils;
|
||||
import com.facebook.sonar.android.utils.SonarUtils;
|
||||
import com.facebook.sonar.android.AndroidSonarClient;
|
||||
import com.facebook.sonar.core.SonarClient;
|
||||
// import com.facebook.sonar.plugins.inspector.DescriptorMapping;
|
||||
// import com.facebook.sonar.plugins.inspector.InspectorSonarPlugin;
|
||||
// import com.facebook.sonar.plugins.network.NetworkSonarPlugin;
|
||||
// import com.facebook.sonar.plugins.network.SonarOkhttpInterceptor;
|
||||
// import com.facebook.sonar.plugins.network.NetworkResponseFormatter;
|
||||
// import okhttp3.OkHttpClient;
|
||||
import com.facebook.sonar.plugins.inspector.DescriptorMapping;
|
||||
import com.facebook.sonar.plugins.inspector.InspectorSonarPlugin;
|
||||
import com.facebook.sonar.plugins.network.NetworkSonarPlugin;
|
||||
import com.facebook.sonar.plugins.network.SonarOkhttpInterceptor;
|
||||
import com.facebook.sonar.plugins.network.NetworkResponseFormatter;
|
||||
import okhttp3.OkHttpClient;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class SonarSampleApplication extends Application {
|
||||
|
||||
//static public OkHttpClient okhttpClient;
|
||||
static public OkHttpClient okhttpClient;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
SoLoader.init(this, false);
|
||||
try {
|
||||
//SoLoader.loadLibrary("sonarfb");
|
||||
SoLoader.loadLibrary("sonarfb");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
// final SonarClient client = AndroidSonarClient.getInstance(this);
|
||||
// final DescriptorMapping descriptorMapping = DescriptorMapping.withDefaults();
|
||||
// client.addPlugin(new InspectorSonarPlugin(this, descriptorMapping));
|
||||
// client.start();
|
||||
// final DescriptorMapping descriptorMapping = DescriptorMapping.withDefaults();
|
||||
//
|
||||
// NetworkSonarPlugin networkPlugin = new NetworkSonarPlugin();
|
||||
// SonarOkhttpInterceptor interceptor = new SonarOkhttpInterceptor(networkPlugin);
|
||||
//
|
||||
// okhttpClient = new OkHttpClient.Builder()
|
||||
// .addNetworkInterceptor(interceptor)
|
||||
// .connectTimeout(60, TimeUnit.SECONDS)
|
||||
// .readTimeout(60, TimeUnit.SECONDS)
|
||||
// .writeTimeout(10, TimeUnit.MINUTES)
|
||||
// .build();
|
||||
//
|
||||
// //LithoSonarDescriptors.add(descriptorMapping);
|
||||
// //client.addPlugin(new InspectorSonarPlugin(this, descriptorMapping));
|
||||
// client.addPlugin(networkPlugin);
|
||||
// client.start();
|
||||
|
||||
final SonarClient client = AndroidSonarClient.getInstance(this);
|
||||
final DescriptorMapping descriptorMapping = DescriptorMapping.withDefaults();
|
||||
|
||||
NetworkSonarPlugin networkPlugin = new NetworkSonarPlugin();
|
||||
SonarOkhttpInterceptor interceptor = new SonarOkhttpInterceptor(networkPlugin);
|
||||
|
||||
okhttpClient = new OkHttpClient.Builder()
|
||||
.addNetworkInterceptor(interceptor)
|
||||
.connectTimeout(60, TimeUnit.SECONDS)
|
||||
.readTimeout(60, TimeUnit.SECONDS)
|
||||
.writeTimeout(10, TimeUnit.MINUTES)
|
||||
.build();
|
||||
|
||||
LithoSonarDescriptors.add(descriptorMapping);
|
||||
client.addPlugin(new InspectorSonarPlugin(this, descriptorMapping));
|
||||
client.addPlugin(networkPlugin);
|
||||
client.start();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user