Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Weather DAO and POJO added #8

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.GestureDetectorCompat;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
Expand Down Expand Up @@ -54,6 +55,8 @@ public class HomeActivity extends FragmentActivity {
*/
private PagerAdapter mPagerAdapter;



@Override
protected void onCreate(Bundle savedInstanceState)
{
Expand All @@ -69,6 +72,15 @@ protected void onCreate(Bundle savedInstanceState)
setupActionBar();
setupDrawer();
setupViewPager();
setupGestureListeners();
}


/**
* Sets/Initializes the Gestures
*/
private void setupGestureListeners() {

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,

Bundle b = getArguments();


// put the string!
TextView tView = (TextView) rootView.findViewById(R.id.pager_counter);
tView.setText(b.getString(ARGS_COUNTER));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package ca.liquidlabs.android.weather.model;

/**
* POJO Class corresponding to Weather
* Created by Alif on 3/12/14.
*/
public class Weather {

private double temp;
private double humidity;
private double high;
private double low;
private double feelsTemp;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package ca.liquidlabs.android.weather.model;

import android.app.Activity;
import android.content.Context;
import android.util.Log;

/**
* Model for retrieving Weather Data
* Abstracts the accessing of Weather Data.
*
* Created by Alif on 3/12/14.
*/
public class WeatherDAO {

// TAG
private static final String TAG = "WeatherData";

// activity using this model must override this data
public interface OnChangeListener<T> {

// callbacks invoked
public void onSuccess(T data);

public void onError(Object e);
}

// context of the Application
private Context mContext;

// reference to dataListener
private OnChangeListener listener;
private static WeatherDAO instance;


//
private WeatherDAO(Context c) {
mContext = c;
}

/**
* @param ctx Pass the Application Context
* @param ls
* @return
*/
private WeatherDAO getInstance(Context ctx, Activity ls) {
if (instance == null) {
instance = new WeatherDAO(ctx);
}

try {
listener = (OnChangeListener) ls;
} catch (ClassCastException e) {
Log.d(TAG, e.toString());
}

return instance;
}


/**
* Gets the Weather Data of the specific city
* @param city
*/
public void getData(String city)
{
// sees if the data exists in the local database
// if it exists, checks if cached/recent enough
// otherwise, makes a request via Android Volley
// and returns the data via callback to Activity


}

/**
* Returns all datas based in collection
*/
public void getData() {

}




}
13 changes: 7 additions & 6 deletions android/app/src/main/res/layout/fragment_screen_slide_page.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/MatchBoth">
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/MatchBoth"
android:id="@+id/screen_slide_layout"
>

<TextView
style="@style/WrapContent"
android:id="@+id/pager_counter"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal|center_vertical"
/>

</RelativeLayout>
</FrameLayout>