Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public void set(final JSONObject action, final JSONObject data, final JSONObject

// Merge with the new input
JSONObject options = action.getJSONObject("options");
JSONObject old_cache = new JSONObject(pref.getString(activity.url, "{}"));
JSONObject old_cache = new JSONObject(pref.getString(activity.getUrl(), "{}"));
JSONObject new_cache = JasonHelper.merge(old_cache, options);

// Update SharedPreferences
String stringified_cache = new_cache.toString();
editor.putString(activity.url, stringified_cache);
editor.putString(activity.getUrl(), stringified_cache);
editor.commit();

// Update model
Expand All @@ -43,7 +43,7 @@ public void reset(final JSONObject action, final JSONObject data, final JSONObje
JasonViewActivity activity = (JasonViewActivity) context;
SharedPreferences pref = context.getSharedPreferences("cache", 0);
SharedPreferences.Editor editor = pref.edit();
editor.remove(activity.url);
editor.remove(activity.getUrl());
editor.commit();

// Update model
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package com.jasonette.seed.Action;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.util.Base64;
import android.util.Log;

import com.jasonette.seed.Core.JasonViewActivity;
import com.jasonette.seed.Helper.JasonHelper;
import com.jasonette.seed.Launcher.Launcher;

import org.json.JSONObject;

import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.util.Iterator;
import java.util.UUID;

Expand All @@ -31,7 +29,7 @@ private void _request(final JSONObject callback, final JSONObject action, final
try{
final JSONObject options = action.getJSONObject("options");
if(options.has("url")){
String url = options.getString("url");
URL url = JasonHelper.resolveUrl(options.getString("url"), context);

// method
String method = "GET";
Expand All @@ -43,8 +41,7 @@ private void _request(final JSONObject callback, final JSONObject action, final
SharedPreferences pref = context.getSharedPreferences("session", 0);
JSONObject session = null;

URI uri_for_session = new URI(url.toLowerCase());
String session_domain = uri_for_session.getHost();
String session_domain = url.getHost();

if(pref.contains(session_domain)){
String str = pref.getString(session_domain, null);
Expand Down Expand Up @@ -80,7 +77,7 @@ private void _request(final JSONObject callback, final JSONObject action, final
}

if(method.equalsIgnoreCase("get")) {
Uri.Builder b = Uri.parse(url).buildUpon();
Uri.Builder b = Uri.parse(url.toString()).buildUpon();

// Attach Params from Session
if(session != null && session.has("body")) {
Expand All @@ -100,7 +97,7 @@ private void _request(final JSONObject callback, final JSONObject action, final
Iterator<String> keysIterator = d.keys();
try {
while (keysIterator.hasNext()) {
String key = (String) keysIterator.next();
String key = keysIterator.next();
String val = d.getString(key);
b.appendQueryParameter(key, val);
}
Expand All @@ -109,9 +106,6 @@ private void _request(final JSONObject callback, final JSONObject action, final
}
}

Uri uri = b.build();
url = uri.toString();

request = builder
.url(url)
.build();
Expand All @@ -133,7 +127,7 @@ private void _request(final JSONObject callback, final JSONObject action, final
Iterator<String> keysIterator = d.keys();
try {
while (keysIterator.hasNext()) {
String key = (String) keysIterator.next();
String key = keysIterator.next();
String val = d.getString(key);
bodyBuilder.add(key, val);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@

import android.content.Context;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.jasonette.seed.Core.JasonViewActivity;
import com.jasonette.seed.Helper.JasonHelper;
import com.jasonette.seed.R;
import com.jasonette.seed.Section.JasonLayout;

import org.json.JSONObject;

import timber.log.Timber;

public class JasonComponent {
public static View build(View view, final JSONObject component, final JSONObject parent, final Context root_context) {
float width = 0;
Expand Down Expand Up @@ -150,7 +149,7 @@ public static View build(View view, final JSONObject component, final JSONObject
return view;

} catch (Exception e){
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
return new View(root_context);
}
}
Expand Down Expand Up @@ -181,7 +180,7 @@ public void onClick(View v) {
}
}
} catch (Exception e) {
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
}
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.jasonette.seed.Component;

import android.content.Context;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;

import timber.log.Timber;

public class JasonComponentFactory {
Map<String, Integer> signature_to_type = new HashMap<String,Integer>();
public static View build(View prototype, final JSONObject component, final JSONObject parent, final Context context) {
Expand Down Expand Up @@ -47,7 +48,7 @@ public static View build(View prototype, final JSONObject component, final JSONO

}
catch (Exception e){
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
}

return new View(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.load.model.LazyHeaders;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.load.resource.gif.GifDrawable;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.BitmapImageViewTarget;
import com.bumptech.glide.request.target.SimpleTarget;
import com.jasonette.seed.Helper.JasonHelper;

import org.json.JSONObject;

import java.net.URI;
Expand Down Expand Up @@ -79,7 +79,7 @@ public static Object resolve_url(JSONObject component, Context context){
return url;
} else {
LazyHeaders.Builder builder = JasonImageComponent.prepare(component, context);
return new GlideUrl(url, builder.build());
return new GlideUrl(JasonHelper.resolveUrl(url, context), builder.build());
}
} catch (Exception e){
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;
Expand All @@ -24,6 +23,8 @@
import org.json.JSONArray;
import org.json.JSONObject;

import timber.log.Timber;


public class JasonMapComponent {
static int EQUATOR_LENGTH = 40075004;
Expand Down Expand Up @@ -64,7 +65,7 @@ public static View build(View view, final JSONObject component, final JSONObject
mapview.getMapAsync(new MapReadyHandler(component, mapview, context));
return mapview;
} catch (Exception e) {
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
}
} else {
try {
Expand All @@ -78,7 +79,7 @@ public static View build(View view, final JSONObject component, final JSONObject
((MapView)view).onResume(); // Trigger onResume
return view;
} catch (Exception e){
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
}
}
return new View(context);
Expand All @@ -95,7 +96,7 @@ private static LatLng getCoordinates(JSONObject position) {
longitude = Double.parseDouble(r[1]);
}
} catch (Exception e) {
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
}
return new LatLng(latitude, longitude);
}
Expand Down Expand Up @@ -168,7 +169,7 @@ public void onMapReady(GoogleMap map) {
}
}
} catch (Exception e) {
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
}
}
}
Expand Down Expand Up @@ -211,4 +212,4 @@ public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
return false;
}
};
}
}
28 changes: 14 additions & 14 deletions app/src/main/java/com/jasonette/seed/Core/JasonModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.util.Log;

import com.jasonette.seed.Helper.JasonHelper;
import com.jasonette.seed.Launcher.Launcher;
Expand All @@ -25,6 +24,7 @@
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import timber.log.Timber;

public class JasonModel{
public String url;
Expand Down Expand Up @@ -56,7 +56,7 @@ public JasonModel(String url, Intent intent, JasonViewActivity view){
try {
this.params = new JSONObject(intent.getStringExtra("params"));
} catch (Exception e) {
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
}
}

Expand All @@ -71,7 +71,7 @@ public JasonModel(String url, Intent intent, JasonViewActivity view){
try {
this.cache = new JSONObject(str);
} catch (Exception e) {
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
}
}

Expand All @@ -86,15 +86,15 @@ public JasonModel(String url, Intent intent, JasonViewActivity view){
this.session = new JSONObject(str);
}
} catch (Exception e){
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
};

try {
JSONObject v = new JSONObject();
v.put("url", this.url);
((Launcher)(this.view.getApplicationContext())).setEnv("view", v);
} catch (Exception e){
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
};
}

Expand Down Expand Up @@ -125,7 +125,7 @@ public void run()
t.start();

} catch (Exception e) {
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
}
}

Expand Down Expand Up @@ -184,7 +184,7 @@ public void onResponse(Call call, final Response response) throws IOException {
}
});
} catch (Exception e){
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
}
}

Expand Down Expand Up @@ -215,7 +215,7 @@ private void include(String res){
try {
latch.await();
} catch (Exception e) {
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
}
}

Expand Down Expand Up @@ -255,7 +255,7 @@ private void resolve_and_build(String res){
}
}
} catch (Exception e){
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
}
}

Expand Down Expand Up @@ -289,13 +289,13 @@ public void onFinished(JSONObject resolved_jason) {
try {
resolve_and_build(resolved_jason.toString());
} catch (Exception e) {
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
}
}
});
JasonParser.getInstance(this.view).parse("json", refs, to_resolve, this.view);
} catch (Exception e){
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
}

}
Expand Down Expand Up @@ -323,13 +323,13 @@ public void onFinished(JSONObject resolved_jason) {
try {
resolve_and_build(resolved_jason.toString());
} catch (Exception e) {
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
}
}
});
JasonParser.getInstance(this.view).parse("json", refs, to_resolve, this.view);
} catch (Exception e){
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
}

}
Expand Down Expand Up @@ -363,7 +363,7 @@ public void set(String name, JSONObject data){
state.put("$env", ((Launcher)(this.view.getApplicationContext())).getEnv());
state.put("$params", params);
} catch (Exception e) {
Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
Timber.w(e);
}
} else {

Expand Down
Loading