Skip to content
Open
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
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

def computeVersionName() {
return "1.0"
}

android {
signingConfigs {
}
Expand Down Expand Up @@ -57,11 +59,14 @@ dependencies {

//compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha1'
compile 'org.greenrobot:eventbus:3.0.0'
compile files('libs/robotium-solo-5.6.1.jar')
//Dagger
//compile 'com.squareup.picasso:picasso:2.5.2'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-core:9.6.1'
compile 'net.hockeyapp.android:HockeySDK:4.0.1'
compile 'org.greenrobot:greendao:3.1.0'
compile 'com.loopj.android:android-async-http:1.4.9'
Expand All @@ -72,20 +77,17 @@ dependencies {
compile 'com.android.support:gridlayout-v7:24.2.1'
compile 'org.apache.commons:commons-io:1.3.2'
compile 'com.firebase:firebase-client-android:2.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.6.1'
compile 'com.facebook.stetho:stetho:1.4.0'
compile 'com.facebook.stetho:stetho-urlconnection:1.4.0'
compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.google.android.gms:play-services-maps:9.6.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
testCompile 'junit:junit:4.12'
compile files('libs/robotium-solo-5.6.1.jar')
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8'
//Dagger
compile 'com.google.dagger:dagger:2.0'
apt 'com.google.dagger:dagger-compiler:2.0'
//compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:cardview-v7:24.2.1'
testCompile 'junit:junit:4.12'
apt 'com.google.dagger:dagger-compiler:2.0'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'org.greenrobot.greendao'
12 changes: 9 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2016. Pritesh Patel, Toronto, Canada
-->
<!-- ~ Copyright (c) 2016. Pritesh Patel, Toronto, Canada -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.moxdroid.interview.tabviewpagerexample">

Expand Down Expand Up @@ -119,9 +117,17 @@
android:name=".recyclerviewexample.ScrollingActivity"
android:label="@string/title_activity_scrolling"
android:theme="@style/AppTheme.NoActionBar">
<<<<<<< HEAD
</activity>
<activity android:name=".TowerOfHanoiActivity">

</activity>
<activity android:name=".python.TestActivity">
=======

</activity>
<activity android:name=".TowerOfHanoiActivity">
>>>>>>> master
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (c) 2016. Pritesh Patel, Toronto, Canada
*/

package com.moxdroid.interview.tabviewpagerexample.python;

/**
* Created by pritesh.patel on 2016-10-21, 1:23 PM.
* ADESA, Canada
*/

import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.util.Log;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;

/**
* Android RestTask (REST) from the Android Recipes book.
*/
public class RestTask extends AsyncTask<HttpUriRequest, Void, String>
{
private static final String TAG = "AARestTask";
public static final String HTTP_RESPONSE = "httpResponse";

private Context mContext;
private HttpClient mClient;
private String mAction;

public RestTask(Context context, String action)
{
mContext = context;
mAction = action;
mClient = new DefaultHttpClient();
}

public RestTask(Context context, String action, HttpClient client)
{
mContext = context;
mAction = action;
mClient = client;
}

@Override
protected String doInBackground(HttpUriRequest... params)
{
try
{
HttpUriRequest request = params[0];
HttpResponse serverResponse = mClient.execute(request);
BasicResponseHandler handler = new BasicResponseHandler();
return handler.handleResponse(serverResponse);
}
catch (Exception e)
{
// TODO handle this properly
e.printStackTrace();
return "";
}
}

@Override
protected void onPostExecute(String result)
{
Log.i(TAG, "RESULT = " + result);
Intent intent = new Intent(mAction);
intent.putExtra(HTTP_RESPONSE, result);

// broadcast the completion
mContext.sendBroadcast(intent);
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2016. Pritesh Patel, Toronto, Canada
*/

package com.moxdroid.interview.tabviewpagerexample.python;

import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.moxdroid.interview.tabviewpagerexample.R;

public class TestActivity extends AppCompatActivity
{

@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);

if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
// if the screen is in landscape mode, we can show the
// dialog in-line with the list so we don't need this activity.
finish();
return;
}

if (savedInstanceState == null) {
TestFragment trendsFragment = new TestFragment();
getSupportFragmentManager()
.beginTransaction()
.add(android.R.id.content, trendsFragment)
.commit();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright (c) 2016. Pritesh Patel, Toronto, Canada
*/

package com.moxdroid.interview.tabviewpagerexample.python;

import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.moxdroid.interview.tabviewpagerexample.R;

import org.apache.http.client.methods.HttpGet;

import java.net.URI;


public class TestFragment extends Fragment
{
private static final String TAG = "AATestFragment";

// you'll want to call a REST service, but for basic network testing i use any url
//private static final String TEST_URL = "http://jsonplaceholder.typicode.com/comments";
private static final String TEST_URL = "http://10.0.2.2:5000/todo/api/v1.0/tasks";
private static final String ACTION_FOR_INTENT_CALLBACK = "OUTPUT_RESPONSE";

ProgressDialog progress;
private TextView ourTextView;


@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ourTextView = (TextView)getActivity().findViewById(R.id.myTextView);
getContent();
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_test, container, false);
}


@Override
public void onResume()
{
super.onResume();
getActivity().registerReceiver(receiver, new IntentFilter(ACTION_FOR_INTENT_CALLBACK));
}

@Override
public void onPause()
{
super.onPause();
getActivity().unregisterReceiver(receiver);
}

private void getContent()
{
// the request
try
{
HttpGet httpGet = new HttpGet(new URI(TEST_URL));
RestTask task = new RestTask(getActivity(), ACTION_FOR_INTENT_CALLBACK);
task.execute(httpGet);
progress = ProgressDialog.show(getActivity(), "Getting Data ...", "Waiting For Results...", true);
}
catch (Exception e)
{
Log.e(TAG, e.getMessage());
}

}

private BroadcastReceiver receiver = new BroadcastReceiver()
{
@Override
public void onReceive(Context context, Intent intent)
{
// clear the progress indicator
if (progress != null)
{
progress.dismiss();
}
String response = intent.getStringExtra(RestTask.HTTP_RESPONSE);
ourTextView.setText(response);
Log.i(TAG, "RESPONSE = " + response);
//
// my old json code was here. this is where you will parse it.
//
}
};
}
18 changes: 18 additions & 0 deletions app/src/main/res/layout/activity_test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2016. Pritesh Patel, Toronto, Canada
-->

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_test"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.moxdroid.interview.tabviewpagerexample.python.TestActivity">

</RelativeLayout>
15 changes: 15 additions & 0 deletions app/src/main/res/layout/fragment_test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<TextView
android:id="@+id/myTextView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Python"
android:textAppearance="?android:attr/textAppearanceMedium" />

</ScrollView>
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Copyright (c) 2016. Pritesh Patel, Toronto, Canada
*/

/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Copyright (c) 2016. Pritesh Patel, Toronto, Canada
*/

/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Copyright (c) 2016. Pritesh Patel, Toronto, Canada
*/

/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Copyright (c) 2016. Pritesh Patel, Toronto, Canada
*/

/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Copyright (c) 2016. Pritesh Patel, Toronto, Canada
*/

/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Copyright (c) 2016. Pritesh Patel, Toronto, Canada
*/

/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
Expand Down
Loading