Skip to content

Commit

Permalink
rewrite & fixup android demo app
Browse files Browse the repository at this point in the history
  • Loading branch information
djodjoni committed Jan 5, 2017
1 parent 24f85e8 commit 519b076
Show file tree
Hide file tree
Showing 60 changed files with 295 additions and 250 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -80,7 +80,7 @@ Jus requires at minimum Java 7 or Android SDK 15.
## Examples

* [java examples]
* [NEW android examples(java 8)]
* [NEW android demo app]
* [android examples (old)]
* [volley to jus migration examples]

Expand Down Expand Up @@ -178,5 +178,5 @@ Jus requires at minimum Java 7 or Android SDK 15.

[java examples]: https://github.com/apptik/jus/tree/master/examples-java
[android examples (old)]: https://github.com/apptik/jus/tree/master/examples-android
[NEW android examples(java 8)]: https://github.com/apptik/jus/tree/master/sample-android
[NEW android demo app]: https://github.com/apptik/jus/tree/master/demo-android
[volley to jus migration examples]: https://github.com/apptik/jus/tree/master/examples-android-volley-migration
4 changes: 2 additions & 2 deletions build.gradle
Expand Up @@ -28,7 +28,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.android.tools.build:gradle:2.2.3'
}
}

Expand All @@ -45,7 +45,7 @@ allprojects {
}

ext {
minSdkVersion = 15
minSdkVersion = 19
compileSdkVersion = 25
buildToolsVersion = '25.0.2'
supportDeps = "25.1.0"
Expand Down
File renamed without changes.
9 changes: 7 additions & 2 deletions sample-android/build.gradle → demo-android/build.gradle
Expand Up @@ -5,7 +5,7 @@ android {
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
applicationId "io.apptik.jus.samples"
applicationId "io.apptik.jus.demoapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.compileSdkVersion
versionCode 1
Expand All @@ -14,6 +14,8 @@ android {
jackOptions {
enabled true
}
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
release {
Expand All @@ -36,7 +38,6 @@ android {
lintOptions {
abortOnError false
}

}

dependencies {
Expand All @@ -60,4 +61,8 @@ dependencies {


compile rootProject.ext.rxjava
androidTestCompile(rootProject.ext.supportTestEspresso, {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile rootProject.ext.junit
}
@@ -1,6 +1,6 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/sic/dev/adt-bundle-mac-x86_64/sdk/tools/proguard/proguard-android.txt
# in /home/djodjo/android-sdks/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
Expand Down
@@ -0,0 +1,26 @@
package io.apptik.jus.demoapp;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("io.apptik.jus.demoapp", appContext.getPackageName());
}
}
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="io.apptik.jus.samples"
xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.apptik.jus.demoapp">

<uses-feature
android:name="android.hardware.touchscreen.multitouch"
Expand Down Expand Up @@ -33,9 +33,9 @@
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.apptik.jus.samples;
package io.apptik.jus.demoapp;


import android.os.Bundle;
Expand Down
@@ -1,4 +1,4 @@
package io.apptik.jus.samples;
package io.apptik.jus.demoapp;

import android.content.Context;
import android.os.Bundle;
Expand All @@ -12,6 +12,7 @@
import io.apptik.comm.jus.ui.NetworkImageView;
import io.apptik.json.JsonObject;
import rx.Subscription;
import rx.functions.Action1;


public class DetailFragment extends Fragment {
Expand All @@ -35,6 +36,10 @@ public static DetailFragment newInstance() {
return fragment;
}

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

@Override
public void onPause() {
Expand All @@ -44,6 +49,17 @@ public void onPause() {
}
}

@Override
public void onResume() {
super.onResume();
subscription = MyJus.hub().getInfo().subscribe(new Action1<JsonObject>() {
@Override
public void call(JsonObject item) {
DetailFragment.this.updateData(item);
}
});
}

@Override
public void onAttach(Context context) {
super.onAttach(context);
Expand All @@ -62,9 +78,5 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
itemId = (TextView) view.findViewById(R.id.details_id);
itemTitle = (TextView) view.findViewById(R.id.details_title);
itemPic = (NetworkImageView) view.findViewById(R.id.details_pic);

subscription = MyJus.hub().getInfo().subscribe(this::updateData);


}
}
@@ -1,4 +1,4 @@
package io.apptik.jus.samples;
package io.apptik.jus.demoapp;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.apptik.jus.samples;
package io.apptik.jus.demoapp;


import android.os.Bundle;
Expand All @@ -25,9 +25,9 @@
import android.view.View;
import android.view.ViewGroup;

import io.apptik.jus.samples.adapter.RecyclerAdapter;
import io.apptik.jus.demoapp.adapter.RecyclerAdapter;

import static io.apptik.jus.samples.dummy.MockData.getMockJsonArray;
import static io.apptik.jus.demoapp.dummy.MockData.getMockJsonArray;


public class ImageListFragment extends Fragment {
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.apptik.jus.samples;
package io.apptik.jus.demoapp;


import android.os.Bundle;
Expand All @@ -26,9 +26,9 @@
import android.view.View;
import android.view.ViewGroup;

import io.apptik.jus.samples.adapter.RecyclerAdapter;
import io.apptik.jus.samples.adapter.RxAdapter;
import io.apptik.jus.samples.api.Instructables;
import io.apptik.jus.demoapp.adapter.RecyclerAdapter;
import io.apptik.jus.demoapp.adapter.RxAdapter;
import io.apptik.jus.demoapp.api.Instructables;


public class InstructablesListFragment extends Fragment {
Expand Down Expand Up @@ -81,10 +81,13 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
}
});
swiperefresh = (SwipeRefreshLayout) v.findViewById(R.id.swiperefresh);
swiperefresh.setOnRefreshListener(() -> {
MyJus.intructablesApi().list(20, 0, Instructables.SORT_RECENT, "id");
offset = 0;
swiperefresh.setRefreshing(false);
swiperefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
MyJus.intructablesApi().list(20, 0, Instructables.SORT_RECENT, "id");
offset = 0;
swiperefresh.setRefreshing(false);
}
});
return v;
}
Expand Down

0 comments on commit 519b076

Please sign in to comment.