commit c3f35caa6b2132e7918e0fd949656ce7268a9908 Author: danijoo Date: Thu Nov 5 16:00:48 2015 +0100 initial diff --git a/Football/.gitignore b/Football/.gitignore new file mode 100644 index 0000000..ee9258c --- /dev/null +++ b/Football/.gitignore @@ -0,0 +1,56 @@ +Thumbs.db#built application files +*.apk +*.ap_ + +# files for the dex VM +*.dex + +# Java class files +*.class + +# generated files +bin/ +gen/ + +# Local configuration file (sdk path, etc) +local.properties + +# Windows thumbnail db +Thumbs.db + +# OSX files +.DS_Store + +# Eclipse project files +.classpath +.project + +# Android Studio +.idea +.idea/workspace.xml +.gradle +build/ +captures/ + +*.iws +*.iml + +# calabash +screenshot* +.irb-history +test_servers + +# crashlytics +crashlytics-build.properties +com_crashlytics_export_strings.xml + +gradle.properties + +screenshot* + +# sbt +00-gradle-generated.sbt +target/ +project/project + + diff --git a/Football/CHANGELOG.md b/Football/CHANGELOG.md new file mode 100644 index 0000000..7563450 --- /dev/null +++ b/Football/CHANGELOG.md @@ -0,0 +1,7 @@ +* fixed internet permission for api level > 22 +* created league enum class to make adding leagues easier, moved league names to Strings.xml +* try/catch clause for share intents to prevent ActivityNotFoundException +* Button and image content description for accessibility +* Implemented RTL layout +* Moved Strings to strings.xml and added translatable flag where required +* added a list widget showing all saved matches \ No newline at end of file diff --git a/Football/app/.gitignore b/Football/app/.gitignore new file mode 100644 index 0000000..4bffab4 --- /dev/null +++ b/Football/app/.gitignore @@ -0,0 +1,6 @@ +/build +project/project +/target/ +.idea +*.iml +target/ \ No newline at end of file diff --git a/Football/app/build.gradle b/Football/app/build.gradle new file mode 100644 index 0000000..4f18d79 --- /dev/null +++ b/Football/app/build.gradle @@ -0,0 +1,25 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "21.1.2" + + defaultConfig { + applicationId "barqsoft.footballscores" + minSdkVersion 10 + targetSdkVersion 21 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:21.0.3' +} diff --git a/Football/app/build.sbt b/Football/app/build.sbt new file mode 100644 index 0000000..dba0d18 --- /dev/null +++ b/Football/app/build.sbt @@ -0,0 +1 @@ +protifySettings \ No newline at end of file diff --git a/Football/app/manifest-merger-release-report.txt b/Football/app/manifest-merger-release-report.txt new file mode 100644 index 0000000..d29661e --- /dev/null +++ b/Football/app/manifest-merger-release-report.txt @@ -0,0 +1,83 @@ +-- Merging decision tree log --- +manifest +ADDED from AndroidManifest.xml:2:1 + xmlns:android + ADDED from AndroidManifest.xml:2:11 + package + ADDED from AndroidManifest.xml:3:5 + INJECTED from AndroidManifest.xml:0:0 + INJECTED from AndroidManifest.xml:0:0 + android:versionName + INJECTED from AndroidManifest.xml:0:0 + INJECTED from AndroidManifest.xml:0:0 + android:versionCode + INJECTED from AndroidManifest.xml:0:0 + INJECTED from AndroidManifest.xml:0:0 +uses-permission#android.permission.INTERNET +ADDED from AndroidManifest.xml:5:5 + android:maxSdkVersion + ADDED from AndroidManifest.xml:7:9 + android:name + ADDED from AndroidManifest.xml:6:9 +application +ADDED from AndroidManifest.xml:9:5 +MERGED from com.android.support:appcompat-v7:21.0.3:16:5 +MERGED from com.android.support:support-v4:21.0.3:16:5 + android:label + ADDED from AndroidManifest.xml:12:9 + android:allowBackup + ADDED from AndroidManifest.xml:10:9 + android:icon + ADDED from AndroidManifest.xml:11:9 + android:theme + ADDED from AndroidManifest.xml:13:9 +activity#barqsoft.footballscores.MainActivity +ADDED from AndroidManifest.xml:14:9 + android:label + ADDED from AndroidManifest.xml:16:13 + android:name + ADDED from AndroidManifest.xml:15:13 +intent-filter#android.intent.action.MAIN+android.intent.category.LAUNCHER +ADDED from AndroidManifest.xml:17:13 +action#android.intent.action.MAIN +ADDED from AndroidManifest.xml:18:17 + android:name + ADDED from AndroidManifest.xml:18:25 +category#android.intent.category.LAUNCHER +ADDED from AndroidManifest.xml:20:17 + android:name + ADDED from AndroidManifest.xml:20:27 +provider#barqsoft.footballscores.ScoresProvider +ADDED from AndroidManifest.xml:24:9 + android:authorities + ADDED from AndroidManifest.xml:26:13 + android:name + ADDED from AndroidManifest.xml:25:13 +activity#barqsoft.footballscores.AboutActivity +ADDED from AndroidManifest.xml:28:9 + android:label + ADDED from AndroidManifest.xml:30:13 + android:parentActivityName + ADDED from AndroidManifest.xml:31:13 + android:name + ADDED from AndroidManifest.xml:29:13 +meta-data#android.support.PARENT_ACTIVITY +ADDED from AndroidManifest.xml:32:13 + android:name + ADDED from AndroidManifest.xml:33:17 + android:value + ADDED from AndroidManifest.xml:34:17 +service#barqsoft.footballscores.service.myFetchService +ADDED from AndroidManifest.xml:36:9 + android:name + ADDED from AndroidManifest.xml:36:18 +uses-sdk +INJECTED from AndroidManifest.xml:0:0 reason: use-sdk injection requested +MERGED from com.android.support:appcompat-v7:21.0.3:15:5 +MERGED from com.android.support:support-v4:21.0.3:15:5 + android:targetSdkVersion + INJECTED from AndroidManifest.xml:0:0 + INJECTED from AndroidManifest.xml:0:0 + android:minSdkVersion + INJECTED from AndroidManifest.xml:0:0 + INJECTED from AndroidManifest.xml:0:0 diff --git a/Football/app/proguard-rules.pro b/Football/app/proguard-rules.pro new file mode 100644 index 0000000..7c5ec42 --- /dev/null +++ b/Football/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in E:\Users\yehya khaled\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/Football/app/src/androidTest/java/barqsoft/footballscores/ApplicationTest.java b/Football/app/src/androidTest/java/barqsoft/footballscores/ApplicationTest.java new file mode 100644 index 0000000..59ba0b6 --- /dev/null +++ b/Football/app/src/androidTest/java/barqsoft/footballscores/ApplicationTest.java @@ -0,0 +1,13 @@ +package barqsoft.footballscores; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/Football/app/src/main/AndroidManifest.xml b/Football/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..526a948 --- /dev/null +++ b/Football/app/src/main/AndroidManifest.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Football/app/src/main/java/barqsoft/footballscores/AboutActivity.java b/Football/app/src/main/java/barqsoft/footballscores/AboutActivity.java new file mode 100644 index 0000000..3ad6a99 --- /dev/null +++ b/Football/app/src/main/java/barqsoft/footballscores/AboutActivity.java @@ -0,0 +1,62 @@ +package barqsoft.footballscores; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v7.app.ActionBarActivity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + + +public class AboutActivity extends ActionBarActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_about); + if (savedInstanceState == null) { + getSupportFragmentManager().beginTransaction() + .add(R.id.container, new PlaceholderFragment()) + .commit(); + } + } + +/* + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_about, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } + */ + + /** + * A placeholder fragment containing a simple view. + */ + public static class PlaceholderFragment extends Fragment { + + public PlaceholderFragment() { + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + return inflater.inflate(R.layout.fragment_about, container, false); + } + } +} diff --git a/Football/app/src/main/java/barqsoft/footballscores/DatabaseContract.java b/Football/app/src/main/java/barqsoft/footballscores/DatabaseContract.java new file mode 100644 index 0000000..d3e6f7a --- /dev/null +++ b/Football/app/src/main/java/barqsoft/footballscores/DatabaseContract.java @@ -0,0 +1,52 @@ +package barqsoft.footballscores; + +import android.content.ContentResolver; +import android.net.Uri; +import android.provider.BaseColumns; + +/** + * Created by yehya khaled on 2/25/2015. + */ +public class DatabaseContract +{ + public static final String SCORES_TABLE = "scores_table"; + public static final class scores_table implements BaseColumns + { + //Table data + public static final String LEAGUE_COL = "league"; + public static final String DATE_COL = "date"; + public static final String TIME_COL = "time"; + public static final String HOME_COL = "home"; + public static final String AWAY_COL = "away"; + public static final String HOME_GOALS_COL = "home_goals"; + public static final String AWAY_GOALS_COL = "away_goals"; + public static final String MATCH_ID = "match_id"; + public static final String MATCH_DAY = "match_day"; + + //public static Uri SCORES_CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH) + //.build(); + + //Types + public static final String CONTENT_TYPE = + ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH; + public static final String CONTENT_ITEM_TYPE = + ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH; + + public static Uri buildScoreWithLeague() + { + return BASE_CONTENT_URI.buildUpon().appendPath("league").build(); + } + public static Uri buildScoreWithId() + { + return BASE_CONTENT_URI.buildUpon().appendPath("id").build(); + } + public static Uri buildScoreWithDate() + { + return BASE_CONTENT_URI.buildUpon().appendPath("date").build(); + } + } + //URI data + public static final String CONTENT_AUTHORITY = "barqsoft.footballscores"; + public static final String PATH = "scores"; + public static Uri BASE_CONTENT_URI = Uri.parse("content://"+CONTENT_AUTHORITY); +} diff --git a/Football/app/src/main/java/barqsoft/footballscores/League.java b/Football/app/src/main/java/barqsoft/footballscores/League.java new file mode 100644 index 0000000..269b419 --- /dev/null +++ b/Football/app/src/main/java/barqsoft/footballscores/League.java @@ -0,0 +1,66 @@ +package barqsoft.footballscores; + +import android.content.Context; +import android.support.annotation.Nullable; + +public enum League { + + BUNDESLIGA1(394, R.string.league_name_bundesliga1), + BUNDESLIGA2(395, R.string.league_name_bundesliga2), + LIGUE1(396, R.string.league_name_league1), + LIGUE2(397, R.string.league_name_league2), + PREMIER_LEAGUE(398, R.string.league_name_premierleague), + PRIMERA_DIVISION(399, R.string.league_name_primeradivision), + SEGUNDA_DIVISION(400, R.string.league_name_segundadivision), + SERIE_A(401, R.string.league_name_seriea), + PRIMERA_LIGA(402, R.string.league_name_primeraliga), + Bundesliga3(403, R.string.league_name_bundesliga3), + EREDIVISIE(404, R.string.league_name_eradivisie), + CHAMPIONS_LEAGUE(405, R.string.league_name_championsleague); + + /** + * @param id of a league + * @return League or null + */ + public static League getLeagueById(int id) { + for(League league : values()) { + if(league.getLeagueId() == id) + return league; + } + return null; + } + + /** + * @param context Context + * @param league League or Null + * @return The name of a given league or an error string if league is null + */ + public static String getLeagueName(Context context, @Nullable League league) { + if(league != null) + return league.getName(context); + else + return context.getString(R.string.league_name_not_found); + } + + + int leagueId; + int nameResId; + + League(int leagueId, int nameResId) { + this.leagueId = leagueId; + this.nameResId = nameResId; + } + + public int getLeagueId() { + return leagueId; + } + + public int getNameResId() { + return nameResId; + } + + public String getName(Context context) { + return context.getString(getNameResId()); + } + +} diff --git a/Football/app/src/main/java/barqsoft/footballscores/MainActivity.java b/Football/app/src/main/java/barqsoft/footballscores/MainActivity.java new file mode 100644 index 0000000..ef60849 --- /dev/null +++ b/Football/app/src/main/java/barqsoft/footballscores/MainActivity.java @@ -0,0 +1,79 @@ +package barqsoft.footballscores; + +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.ActionBarActivity; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; + +public class MainActivity extends ActionBarActivity +{ + public static int selected_match_id; + public static int current_fragment = 2; + public static String LOG_TAG = "MainActivity"; + private final String save_tag = "Save Test"; + private PagerFragment my_main; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + Log.d(LOG_TAG, "Reached MainActivity onCreate"); + if (savedInstanceState == null) { + my_main = new PagerFragment(); + getSupportFragmentManager().beginTransaction() + .add(R.id.container, my_main) + .commit(); + } + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_about) + { + Intent start_about = new Intent(this,AboutActivity.class); + startActivity(start_about); + return true; + } + + return super.onOptionsItemSelected(item); + } + + @Override + protected void onSaveInstanceState(Bundle outState) + { + Log.v(save_tag,"will save"); + Log.v(save_tag,"fragment: "+String.valueOf(my_main.mPagerHandler.getCurrentItem())); + Log.v(save_tag,"selected id: "+selected_match_id); + outState.putInt("Pager_Current",my_main.mPagerHandler.getCurrentItem()); + outState.putInt("Selected_match",selected_match_id); + getSupportFragmentManager().putFragment(outState,"my_main",my_main); + super.onSaveInstanceState(outState); + } + + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) + { + Log.v(save_tag,"will retrive"); + Log.v(save_tag,"fragment: "+String.valueOf(savedInstanceState.getInt("Pager_Current"))); + Log.v(save_tag,"selected id: "+savedInstanceState.getInt("Selected_match")); + current_fragment = savedInstanceState.getInt("Pager_Current"); + selected_match_id = savedInstanceState.getInt("Selected_match"); + my_main = (PagerFragment) getSupportFragmentManager().getFragment(savedInstanceState,"my_main"); + super.onRestoreInstanceState(savedInstanceState); + } +} diff --git a/Football/app/src/main/java/barqsoft/footballscores/MainScreenFragment.java b/Football/app/src/main/java/barqsoft/footballscores/MainScreenFragment.java new file mode 100644 index 0000000..1022b39 --- /dev/null +++ b/Football/app/src/main/java/barqsoft/footballscores/MainScreenFragment.java @@ -0,0 +1,104 @@ +package barqsoft.footballscores; + +import android.content.Intent; +import android.database.Cursor; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.CursorLoader; +import android.support.v4.content.Loader; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.ListView; + +import barqsoft.footballscores.service.myFetchService; + +/** + * A placeholder fragment containing a simple view. + */ +public class MainScreenFragment extends Fragment implements LoaderManager.LoaderCallbacks +{ + public scoresAdapter mAdapter; + public static final int SCORES_LOADER = 0; + private String[] fragmentdate = new String[1]; + private int last_selected_item = -1; + + public MainScreenFragment() + { + } + + private void update_scores() + { + Intent service_start = new Intent(getActivity(), myFetchService.class); + getActivity().startService(service_start); + } + public void setFragmentDate(String date) + { + fragmentdate[0] = date; + } + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + final Bundle savedInstanceState) { + update_scores(); + View rootView = inflater.inflate(R.layout.fragment_main, container, false); + final ListView score_list = (ListView) rootView.findViewById(R.id.scores_list); + mAdapter = new scoresAdapter(getActivity(),null,0); + score_list.setAdapter(mAdapter); + getLoaderManager().initLoader(SCORES_LOADER,null,this); + mAdapter.detail_match_id = MainActivity.selected_match_id; + score_list.setOnItemClickListener(new AdapterView.OnItemClickListener() + { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) + { + ViewHolder selected = (ViewHolder) view.getTag(); + mAdapter.detail_match_id = selected.match_id; + MainActivity.selected_match_id = (int) selected.match_id; + mAdapter.notifyDataSetChanged(); + } + }); + return rootView; + } + + @Override + public Loader onCreateLoader(int i, Bundle bundle) + { + return new CursorLoader(getActivity(),DatabaseContract.scores_table.buildScoreWithDate(), + null,null,fragmentdate,null); + } + + @Override + public void onLoadFinished(Loader cursorLoader, Cursor cursor) + { + //Log.v(FetchScoreTask.LOG_TAG,"loader finished"); + //cursor.moveToFirst(); + /* + while (!cursor.isAfterLast()) + { + Log.v(FetchScoreTask.LOG_TAG,cursor.getString(1)); + cursor.moveToNext(); + } + */ + + int i = 0; + cursor.moveToFirst(); + while (!cursor.isAfterLast()) + { + i++; + cursor.moveToNext(); + } + //Log.v(FetchScoreTask.LOG_TAG,"Loader query: " + String.valueOf(i)); + mAdapter.swapCursor(cursor); + //mAdapter.notifyDataSetChanged(); + } + + @Override + public void onLoaderReset(Loader cursorLoader) + { + mAdapter.swapCursor(null); + } + + +} diff --git a/Football/app/src/main/java/barqsoft/footballscores/PagerFragment.java b/Football/app/src/main/java/barqsoft/footballscores/PagerFragment.java new file mode 100644 index 0000000..d1212b0 --- /dev/null +++ b/Football/app/src/main/java/barqsoft/footballscores/PagerFragment.java @@ -0,0 +1,116 @@ +package barqsoft.footballscores; + +import android.content.Context; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentStatePagerAdapter; +import android.support.v4.view.ViewPager; +import android.text.format.Time; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * Created by yehya khaled on 2/27/2015. + */ +public class PagerFragment extends Fragment +{ + public static final String TAG = PagerFragment.class.getSimpleName(); + public static final int NUM_PAGES = 5; + public ViewPager mPagerHandler; + private myPageAdapter mPagerAdapter; + private MainScreenFragment[] viewFragments = new MainScreenFragment[5]; + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) + { + View rootView = inflater.inflate(R.layout.pager_fragment, container, false); + mPagerHandler = (ViewPager) rootView.findViewById(R.id.pager); + boolean isRTL = getResources().getBoolean(R.bool.is_rtl); + Log.d(TAG, "RTL: " + (isRTL ? "enabled" : "disabled")); + mPagerAdapter = new myPageAdapter(getChildFragmentManager(), isRTL); + for (int i = 0;i < NUM_PAGES;i++) + { + Date fragmentdate = new Date(System.currentTimeMillis()+((i-2)*86400000)); + SimpleDateFormat mformat = new SimpleDateFormat("yyyy-MM-dd", getActivity().getResources().getConfiguration().locale); + viewFragments[i] = new MainScreenFragment(); + viewFragments[i].setFragmentDate(mformat.format(fragmentdate)); + } + mPagerHandler.setAdapter(mPagerAdapter); + mPagerHandler.setCurrentItem(MainActivity.current_fragment); + return rootView; + } + private class myPageAdapter extends FragmentStatePagerAdapter + { + boolean isRTL; + + @Override + public Fragment getItem(int i) + { + if(isRTL) + i = getRTLPosition(i); + return viewFragments[i]; + } + + @Override + public int getCount() + { + return NUM_PAGES; + } + + public myPageAdapter(FragmentManager fm, boolean rtl) + { + super(fm); + this.isRTL = rtl; + } + + // Returns the page title for the top indicator + @Override + public CharSequence getPageTitle(int position) + { + if(isRTL) + position = getRTLPosition(position); + return getDayName(getActivity(),System.currentTimeMillis()+((position-2)*86400000)); + } + + /** + * @param position actual adapter position + * @return the RTL position + */ + private int getRTLPosition(int position) { + return getCount() - position - 1; + } + + public String getDayName(Context context, long dateInMillis) { + // If the date is today, return the localized version of "Today" instead of the actual + // day name. + + Time t = new Time(); + t.setToNow(); + int julianDay = Time.getJulianDay(dateInMillis, t.gmtoff); + int currentJulianDay = Time.getJulianDay(System.currentTimeMillis(), t.gmtoff); + if (julianDay == currentJulianDay) { + return context.getString(R.string.today); + } else if ( julianDay == currentJulianDay +1 ) { + return context.getString(R.string.tomorrow); + } + else if ( julianDay == currentJulianDay -1) + { + return context.getString(R.string.yesterday); + } + else + { + Time time = new Time(); + time.setToNow(); + // Otherwise, the format is just the day of the week (e.g "Wednesday". + SimpleDateFormat dayFormat = new SimpleDateFormat("EEEE", getActivity().getResources().getConfiguration().locale); + return dayFormat.format(dateInMillis); + } + } + } +} diff --git a/Football/app/src/main/java/barqsoft/footballscores/ScoresDBHelper.java b/Football/app/src/main/java/barqsoft/footballscores/ScoresDBHelper.java new file mode 100644 index 0000000..9eabdd6 --- /dev/null +++ b/Football/app/src/main/java/barqsoft/footballscores/ScoresDBHelper.java @@ -0,0 +1,46 @@ +package barqsoft.footballscores; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; + +import barqsoft.footballscores.DatabaseContract.scores_table; + +/** + * Created by yehya khaled on 2/25/2015. + */ +public class ScoresDBHelper extends SQLiteOpenHelper +{ + public static final String DATABASE_NAME = "Scores.db"; + private static final int DATABASE_VERSION = 2; + public ScoresDBHelper(Context context) + { + super(context,DATABASE_NAME,null,DATABASE_VERSION); + } + + @Override + public void onCreate(SQLiteDatabase db) + { + final String CreateScoresTable = "CREATE TABLE " + DatabaseContract.SCORES_TABLE + " (" + + scores_table._ID + " INTEGER PRIMARY KEY," + + scores_table.DATE_COL + " TEXT NOT NULL," + + scores_table.TIME_COL + " INTEGER NOT NULL," + + scores_table.HOME_COL + " TEXT NOT NULL," + + scores_table.AWAY_COL + " TEXT NOT NULL," + + scores_table.LEAGUE_COL + " INTEGER NOT NULL," + + scores_table.HOME_GOALS_COL + " TEXT NOT NULL," + + scores_table.AWAY_GOALS_COL + " TEXT NOT NULL," + + scores_table.MATCH_ID + " INTEGER NOT NULL," + + scores_table.MATCH_DAY + " INTEGER NOT NULL," + + " UNIQUE ("+scores_table.MATCH_ID+") ON CONFLICT REPLACE" + + " );"; + db.execSQL(CreateScoresTable); + } + + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) + { + //Remove old values when upgrading. + db.execSQL("DROP TABLE IF EXISTS " + DatabaseContract.SCORES_TABLE); + } +} diff --git a/Football/app/src/main/java/barqsoft/footballscores/ScoresProvider.java b/Football/app/src/main/java/barqsoft/footballscores/ScoresProvider.java new file mode 100644 index 0000000..15bb98d --- /dev/null +++ b/Football/app/src/main/java/barqsoft/footballscores/ScoresProvider.java @@ -0,0 +1,170 @@ +package barqsoft.footballscores; + +import android.content.ContentProvider; +import android.content.ContentValues; +import android.content.UriMatcher; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteQueryBuilder; +import android.net.Uri; + +/** + * Created by yehya khaled on 2/25/2015. + */ +public class ScoresProvider extends ContentProvider +{ + private static ScoresDBHelper mOpenHelper; + private static final int MATCHES = 100; + private static final int MATCHES_WITH_LEAGUE = 101; + private static final int MATCHES_WITH_ID = 102; + private static final int MATCHES_WITH_DATE = 103; + private UriMatcher muriMatcher = buildUriMatcher(); + private static final SQLiteQueryBuilder ScoreQuery = + new SQLiteQueryBuilder(); + private static final String SCORES_BY_LEAGUE = DatabaseContract.scores_table.LEAGUE_COL + " = ?"; + private static final String SCORES_BY_DATE = + DatabaseContract.scores_table.DATE_COL + " LIKE ?"; + private static final String SCORES_BY_ID = + DatabaseContract.scores_table.MATCH_ID + " = ?"; + + + static UriMatcher buildUriMatcher() { + final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); + final String authority = DatabaseContract.BASE_CONTENT_URI.toString(); + matcher.addURI(authority, null , MATCHES); + matcher.addURI(authority, "league" , MATCHES_WITH_LEAGUE); + matcher.addURI(authority, "id" , MATCHES_WITH_ID); + matcher.addURI(authority, "date" , MATCHES_WITH_DATE); + return matcher; + } + + private int match_uri(Uri uri) + { + String link = uri.toString(); + { + if(link.contentEquals(DatabaseContract.BASE_CONTENT_URI.toString())) + { + return MATCHES; + } + else if(link.contentEquals(DatabaseContract.scores_table.buildScoreWithDate().toString())) + { + return MATCHES_WITH_DATE; + } + else if(link.contentEquals(DatabaseContract.scores_table.buildScoreWithId().toString())) + { + return MATCHES_WITH_ID; + } + else if(link.contentEquals(DatabaseContract.scores_table.buildScoreWithLeague().toString())) + { + return MATCHES_WITH_LEAGUE; + } + } + return -1; + } + @Override + public boolean onCreate() + { + mOpenHelper = new ScoresDBHelper(getContext()); + return false; + } + + @Override + public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) + { + return 0; + } + + @Override + public String getType(Uri uri) + { + final int match = muriMatcher.match(uri); + switch (match) { + case MATCHES: + return DatabaseContract.scores_table.CONTENT_TYPE; + case MATCHES_WITH_LEAGUE: + return DatabaseContract.scores_table.CONTENT_TYPE; + case MATCHES_WITH_ID: + return DatabaseContract.scores_table.CONTENT_ITEM_TYPE; + case MATCHES_WITH_DATE: + return DatabaseContract.scores_table.CONTENT_TYPE; + default: + throw new UnsupportedOperationException("Unknown uri :" + uri ); + } + } + + @Override + public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) + { + Cursor retCursor; + //Log.v(FetchScoreTask.LOG_TAG,uri.getPathSegments().toString()); + int match = match_uri(uri); + //Log.v(FetchScoreTask.LOG_TAG,SCORES_BY_LEAGUE); + //Log.v(FetchScoreTask.LOG_TAG,selectionArgs[0]); + //Log.v(FetchScoreTask.LOG_TAG,String.valueOf(match)); + switch (match) + { + case MATCHES: retCursor = mOpenHelper.getReadableDatabase().query( + DatabaseContract.SCORES_TABLE, + projection,null,null,null,null,sortOrder); break; + case MATCHES_WITH_DATE: + //Log.v(FetchScoreTask.LOG_TAG,selectionArgs[1]); + //Log.v(FetchScoreTask.LOG_TAG,selectionArgs[2]); + retCursor = mOpenHelper.getReadableDatabase().query( + DatabaseContract.SCORES_TABLE, + projection,SCORES_BY_DATE,selectionArgs,null,null,sortOrder); break; + case MATCHES_WITH_ID: retCursor = mOpenHelper.getReadableDatabase().query( + DatabaseContract.SCORES_TABLE, + projection,SCORES_BY_ID,selectionArgs,null,null,sortOrder); break; + case MATCHES_WITH_LEAGUE: retCursor = mOpenHelper.getReadableDatabase().query( + DatabaseContract.SCORES_TABLE, + projection,SCORES_BY_LEAGUE,selectionArgs,null,null,sortOrder); break; + default: throw new UnsupportedOperationException("Unknown Uri" + uri); + } + retCursor.setNotificationUri(getContext().getContentResolver(),uri); + return retCursor; + } + + @Override + public Uri insert(Uri uri, ContentValues values) { + + return null; + } + + @Override + public int bulkInsert(Uri uri, ContentValues[] values) + { + SQLiteDatabase db = mOpenHelper.getWritableDatabase(); + //db.delete(DatabaseContract.SCORES_TABLE,null,null); + //Log.v(FetchScoreTask.LOG_TAG,String.valueOf(muriMatcher.match(uri))); + switch (match_uri(uri)) + { + case MATCHES: + db.beginTransaction(); + int returncount = 0; + try + { + for(ContentValues value : values) + { + long _id = db.insertWithOnConflict(DatabaseContract.SCORES_TABLE, null, value, + SQLiteDatabase.CONFLICT_REPLACE); + if (_id != -1) + { + returncount++; + } + } + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + } + getContext().getContentResolver().notifyChange(uri,null); + return returncount; + default: + return super.bulkInsert(uri,values); + } + } + + @Override + public int delete(Uri uri, String selection, String[] selectionArgs) { + return 0; + } +} diff --git a/Football/app/src/main/java/barqsoft/footballscores/Utilies.java b/Football/app/src/main/java/barqsoft/footballscores/Utilies.java new file mode 100644 index 0000000..3d37293 --- /dev/null +++ b/Football/app/src/main/java/barqsoft/footballscores/Utilies.java @@ -0,0 +1,78 @@ +package barqsoft.footballscores; + +import android.content.Context; + +/** + * Created by yehya khaled on 3/3/2015. + */ +public class Utilies +{ + + public static String getLeague(Context context, int league_num) + { + League league = League.getLeagueById(league_num); + return League.getLeagueName(context, league); + } + public static String getMatchDay(Context context, int match_day, int league_num) + { + if(league_num == League.CHAMPIONS_LEAGUE.getLeagueId()) + { + if (match_day <= 6) + { + return context.getString(R.string.matchday_uefa_6); + } + else if(match_day == 7 || match_day == 8) + { + return context.getString(R.string.matchday_uefa_first_knockout); + } + else if(match_day == 9 || match_day == 10) + { + return context.getString(R.string.matchday_uefa_quarterfinal); + } + else if(match_day == 11 || match_day == 12) + { + return context.getString(R.string.matchday_uefa_semifinal); + } + else + { + return context.getString(R.string.matchday_uefa_final); + } + } + else + { + return context.getString(R.string.matchday, match_day); + } + } + + public static String getScores(Context context, int home_goals,int awaygoals) + { + if(home_goals < 0 || awaygoals < 0) + { + return context.getString(R.string.scores, "", "").trim(); + } + else + { + return context.getString(R.string.scores, home_goals, awaygoals); + } + } + + public static int getTeamCrestByTeamName (String teamname) + { + if (teamname==null){return R.drawable.no_icon;} + switch (teamname) + { //This is the set of icons that are currently in the app. Feel free to find and add more + //as you go. + case "Arsenal London FC" : return R.drawable.arsenal; + case "Manchester United FC" : return R.drawable.manchester_united; + case "Swansea City" : return R.drawable.swansea_city_afc; + case "Leicester City" : return R.drawable.leicester_city_fc_hd_logo; + case "Everton FC" : return R.drawable.everton_fc_logo1; + case "West Ham United FC" : return R.drawable.west_ham; + case "Tottenham Hotspur FC" : return R.drawable.tottenham_hotspur; + case "West Bromwich Albion" : return R.drawable.west_bromwich_albion_hd_logo; + case "Sunderland AFC" : return R.drawable.sunderland; + case "Stoke City FC" : return R.drawable.stoke_city; + default: return R.drawable.no_icon; + } + } +} diff --git a/Football/app/src/main/java/barqsoft/footballscores/ViewHolder.java b/Football/app/src/main/java/barqsoft/footballscores/ViewHolder.java new file mode 100644 index 0000000..f327fd0 --- /dev/null +++ b/Football/app/src/main/java/barqsoft/footballscores/ViewHolder.java @@ -0,0 +1,28 @@ +package barqsoft.footballscores; + +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +/** + * Created by yehya khaled on 2/26/2015. + */ +public class ViewHolder +{ + public TextView home_name; + public TextView away_name; + public TextView score; + public TextView date; + public ImageView home_crest; + public ImageView away_crest; + public double match_id; + public ViewHolder(View view) + { + home_name = (TextView) view.findViewById(R.id.home_name); + away_name = (TextView) view.findViewById(R.id.away_name); + score = (TextView) view.findViewById(R.id.score_textview); + date = (TextView) view.findViewById(R.id.data_textview); + home_crest = (ImageView) view.findViewById(R.id.home_crest); + away_crest = (ImageView) view.findViewById(R.id.away_crest); + } +} diff --git a/Football/app/src/main/java/barqsoft/footballscores/scoresAdapter.java b/Football/app/src/main/java/barqsoft/footballscores/scoresAdapter.java new file mode 100644 index 0000000..fc123ca --- /dev/null +++ b/Football/app/src/main/java/barqsoft/footballscores/scoresAdapter.java @@ -0,0 +1,109 @@ +package barqsoft.footballscores; + +import android.content.ActivityNotFoundException; +import android.content.Context; +import android.content.Intent; +import android.database.Cursor; +import android.support.v4.widget.CursorAdapter; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.TextView; +import android.widget.Toast; + +/** + * Created by yehya khaled on 2/26/2015. + */ +public class scoresAdapter extends CursorAdapter +{ + public static final int COL_HOME = 3; + public static final int COL_AWAY = 4; + public static final int COL_HOME_GOALS = 6; + public static final int COL_AWAY_GOALS = 7; + public static final int COL_DATE = 1; + public static final int COL_LEAGUE = 5; + public static final int COL_MATCHDAY = 9; + public static final int COL_ID = 8; + public static final int COL_MATCHTIME = 2; + public double detail_match_id = 0; + public scoresAdapter(Context context,Cursor cursor,int flags) + { + super(context,cursor,flags); + } + + @Override + public View newView(Context context, Cursor cursor, ViewGroup parent) + { + View mItem = LayoutInflater.from(context).inflate(R.layout.scores_list_item, parent, false); + ViewHolder mHolder = new ViewHolder(mItem); + mItem.setTag(mHolder); + //Log.v(FetchScoreTask.LOG_TAG,"new View inflated"); + return mItem; + } + + @Override + public void bindView(View view, final Context context, Cursor cursor) + { + final ViewHolder mHolder = (ViewHolder) view.getTag(); + mHolder.home_name.setText(cursor.getString(COL_HOME)); + mHolder.away_name.setText(cursor.getString(COL_AWAY)); + mHolder.date.setText(cursor.getString(COL_MATCHTIME)); + mHolder.score.setText(Utilies.getScores(context, cursor.getInt(COL_HOME_GOALS),cursor.getInt(COL_AWAY_GOALS))); + mHolder.match_id = cursor.getDouble(COL_ID); + mHolder.home_crest.setImageResource(Utilies.getTeamCrestByTeamName( + cursor.getString(COL_HOME))); + mHolder.away_crest.setImageResource(Utilies.getTeamCrestByTeamName( + cursor.getString(COL_AWAY) + )); + //Log.v(FetchScoreTask.LOG_TAG,mHolder.home_name.getText() + " Vs. " + mHolder.away_name.getText() +" id " + String.valueOf(mHolder.match_id)); + //Log.v(FetchScoreTask.LOG_TAG,String.valueOf(detail_match_id)); + LayoutInflater vi = (LayoutInflater) context.getApplicationContext() + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + View v = vi.inflate(R.layout.detail_fragment, null); + ViewGroup container = (ViewGroup) view.findViewById(R.id.details_fragment_container); + if(mHolder.match_id == detail_match_id) + { + //Log.v(FetchScoreTask.LOG_TAG,"will insert extraView"); + + container.addView(v, 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT + , ViewGroup.LayoutParams.MATCH_PARENT)); + TextView match_day = (TextView) v.findViewById(R.id.matchday_textview); + match_day.setText(Utilies.getMatchDay(context, cursor.getInt(COL_MATCHDAY), + cursor.getInt(COL_LEAGUE))); + TextView league = (TextView) v.findViewById(R.id.league_textview); + league.setText(Utilies.getLeague(context, cursor.getInt(COL_LEAGUE))); + Button share_button = (Button) v.findViewById(R.id.share_button); + share_button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) + { + //add Share Action. Catch clause to prevent app from crashing if theres no activity to share with + try { + context.startActivity(createShareForecastIntent(mHolder.home_name.getText() + " " + + mHolder.score.getText() + " " + mHolder.away_name.getText() + " ")); + } catch(ActivityNotFoundException e) { + Log.e("ScoresAdapter", "No activity for share intent found"); + Toast.makeText(context, R.string.match_share_not_found, Toast.LENGTH_SHORT).show(); + } + } + }); + } + else + { + container.removeAllViews(); + } + + } + public Intent createShareForecastIntent(String ShareText) { + String hashtag = mContext.getString(R.string.hashtag); + + Intent shareIntent = new Intent(Intent.ACTION_SEND); + shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); + shareIntent.setType("text/plain"); + shareIntent.putExtra(Intent.EXTRA_TEXT, ShareText + hashtag); + return shareIntent; + } + +} diff --git a/Football/app/src/main/java/barqsoft/footballscores/service/myFetchService.java b/Football/app/src/main/java/barqsoft/footballscores/service/myFetchService.java new file mode 100644 index 0000000..13cb751 --- /dev/null +++ b/Football/app/src/main/java/barqsoft/footballscores/service/myFetchService.java @@ -0,0 +1,263 @@ +package barqsoft.footballscores.service; + +import android.app.IntentService; +import android.content.ContentValues; +import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.util.Log; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; +import java.util.Vector; + +import barqsoft.footballscores.DatabaseContract; +import barqsoft.footballscores.League; +import barqsoft.footballscores.R; + +/** + * Created by yehya khaled on 3/2/2015. + */ +public class myFetchService extends IntentService +{ + public static final String LOG_TAG = "myFetchService"; + public myFetchService() + { + super("myFetchService"); + } + + @Override + protected void onHandleIntent(Intent intent) + { + getData("n2"); + getData("p2"); + + return; + } + + private void getData (String timeFrame) + { + //Creating fetch URL + final String BASE_URL = "http://api.football-data.org/alpha/fixtures"; //Base URL + final String QUERY_TIME_FRAME = "timeFrame"; //Time Frame parameter to determine days + //final String QUERY_MATCH_DAY = "matchday"; + + Uri fetch_build = Uri.parse(BASE_URL).buildUpon(). + appendQueryParameter(QUERY_TIME_FRAME, timeFrame).build(); + //Log.v(LOG_TAG, "The url we are looking at is: "+fetch_build.toString()); //log spam + HttpURLConnection m_connection = null; + BufferedReader reader = null; + String JSON_data = null; + //Opening Connection + try { + URL fetch = new URL(fetch_build.toString()); + m_connection = (HttpURLConnection) fetch.openConnection(); + m_connection.setRequestMethod("GET"); + m_connection.addRequestProperty("X-Auth-Token",getString(R.string.api_key)); + m_connection.connect(); + + // Read the input stream into a String + InputStream inputStream = m_connection.getInputStream(); + StringBuffer buffer = new StringBuffer(); + if (inputStream == null) { + // Nothing to do. + return; + } + reader = new BufferedReader(new InputStreamReader(inputStream)); + + String line; + while ((line = reader.readLine()) != null) { + // Since it's JSON, adding a newline isn't necessary (it won't affect parsing) + // But it does make debugging a *lot* easier if you print out the completed + // buffer for debugging. + buffer.append(line + "\n"); + } + if (buffer.length() == 0) { + // Stream was empty. No point in parsing. + return; + } + JSON_data = buffer.toString(); + } + catch (Exception e) + { + Log.e(LOG_TAG,"Exception here" + e.getMessage()); + } + finally { + if(m_connection != null) + { + m_connection.disconnect(); + } + if (reader != null) + { + try { + reader.close(); + } + catch (IOException e) + { + Log.e(LOG_TAG,"Error Closing Stream"); + } + } + } + try { + if (JSON_data != null) { + //This bit is to check if the data contains any matches. If not, we call processJson on the dummy data + JSONArray matches = new JSONObject(JSON_data).getJSONArray("fixtures"); + if (matches.length() == 0) { + //if there is no data, call the function on dummy data + //this is expected behavior during the off season. + processJSONdata(getString(R.string.dummy_data), getApplicationContext(), false); + return; + } + + + processJSONdata(JSON_data, getApplicationContext(), true); + } else { + //Could not Connect + Log.d(LOG_TAG, "Could not connect to server."); + } + } + catch(Exception e) + { + Log.e(LOG_TAG,e.getMessage()); + } + } + private void processJSONdata (String JSONdata,Context mContext, boolean isReal) + { + final String SEASON_LINK = "http://api.football-data.org/alpha/soccerseasons/"; + final String MATCH_LINK = "http://api.football-data.org/alpha/fixtures/"; + final String FIXTURES = "fixtures"; + final String LINKS = "_links"; + final String SOCCER_SEASON = "soccerseason"; + final String SELF = "self"; + final String MATCH_DATE = "date"; + final String HOME_TEAM = "homeTeamName"; + final String AWAY_TEAM = "awayTeamName"; + final String RESULT = "result"; + final String HOME_GOALS = "goalsHomeTeam"; + final String AWAY_GOALS = "goalsAwayTeam"; + final String MATCH_DAY = "matchday"; + + //Match data + League league = null; + String mDate = null; + String mTime = null; + String Home = null; + String Away = null; + String Home_goals = null; + String Away_goals = null; + String match_id = null; + String match_day = null; + + + try { + JSONArray matches = new JSONObject(JSONdata).getJSONArray(FIXTURES); + + + //ContentValues to be inserted + Vector values = new Vector (matches.length()); + for(int i = 0;i < matches.length();i++) + { + + JSONObject match_data = matches.getJSONObject(i); + String leagueString = match_data.getJSONObject(LINKS).getJSONObject(SOCCER_SEASON). + getString("href"); + leagueString = leagueString.replace(SEASON_LINK,""); + try { + league = League.getLeagueById(Integer.valueOf(leagueString)); + } catch (NumberFormatException e) { + league = null; + } + //This if statement controls which leagues we're interested in the data from. + //add leagues here in order to have them be added to the DB. + // If you are finding no data in the app, check that this contains all the leagues. + // If it doesn't, that can cause an empty DB, bypassing the dummy data routine. + if(league != null) + { + match_id = match_data.getJSONObject(LINKS).getJSONObject(SELF). + getString("href"); + match_id = match_id.replace(MATCH_LINK, ""); + if(!isReal){ + //This if statement changes the match ID of the dummy data so that it all goes into the database + match_id=match_id+Integer.toString(i); + } + + mDate = match_data.getString(MATCH_DATE); + mTime = mDate.substring(mDate.indexOf("T") + 1, mDate.indexOf("Z")); + mDate = mDate.substring(0,mDate.indexOf("T")); + SimpleDateFormat match_date = new SimpleDateFormat("yyyy-MM-ddHH:mm:ss"); + match_date.setTimeZone(TimeZone.getTimeZone("UTC")); + try { + Date parseddate = match_date.parse(mDate+mTime); + SimpleDateFormat new_date = new SimpleDateFormat("yyyy-MM-dd:HH:mm"); + new_date.setTimeZone(TimeZone.getDefault()); + mDate = new_date.format(parseddate); + mTime = mDate.substring(mDate.indexOf(":") + 1); + mDate = mDate.substring(0,mDate.indexOf(":")); + + if(!isReal){ + //This if statement changes the dummy data's date to match our current date range. + Date fragmentdate = new Date(System.currentTimeMillis()+((i-2)*86400000)); + SimpleDateFormat mformat = new SimpleDateFormat("yyyy-MM-dd"); + mDate=mformat.format(fragmentdate); + } + } + catch (Exception e) + { + Log.d(LOG_TAG, "error here!"); + Log.e(LOG_TAG,e.getMessage()); + } + Home = match_data.getString(HOME_TEAM); + Away = match_data.getString(AWAY_TEAM); + Home_goals = match_data.getJSONObject(RESULT).getString(HOME_GOALS); + Away_goals = match_data.getJSONObject(RESULT).getString(AWAY_GOALS); + match_day = match_data.getString(MATCH_DAY); + ContentValues match_values = new ContentValues(); + match_values.put(DatabaseContract.scores_table.MATCH_ID,match_id); + match_values.put(DatabaseContract.scores_table.DATE_COL,mDate); + match_values.put(DatabaseContract.scores_table.TIME_COL,mTime); + match_values.put(DatabaseContract.scores_table.HOME_COL,Home); + match_values.put(DatabaseContract.scores_table.AWAY_COL,Away); + match_values.put(DatabaseContract.scores_table.HOME_GOALS_COL,Home_goals); + match_values.put(DatabaseContract.scores_table.AWAY_GOALS_COL,Away_goals); + match_values.put(DatabaseContract.scores_table.LEAGUE_COL,league.getLeagueId()); + match_values.put(DatabaseContract.scores_table.MATCH_DAY,match_day); + //log spam + + //Log.v(LOG_TAG,match_id); + //Log.v(LOG_TAG,mDate); + //Log.v(LOG_TAG,mTime); + //Log.v(LOG_TAG,Home); + //Log.v(LOG_TAG,Away); + //Log.v(LOG_TAG,Home_goals); + //Log.v(LOG_TAG,Away_goals); + + values.add(match_values); + } + } + int inserted_data = 0; + ContentValues[] insert_data = new ContentValues[values.size()]; + values.toArray(insert_data); + inserted_data = mContext.getContentResolver().bulkInsert( + DatabaseContract.BASE_CONTENT_URI,insert_data); + + //Log.v(LOG_TAG,"Succesfully Inserted : " + String.valueOf(inserted_data)); + } + catch (JSONException e) + { + Log.e(LOG_TAG,e.getMessage()); + } + + } +} + diff --git a/Football/app/src/main/java/barqsoft/footballscores/widget/ListWidgetProvider.java b/Football/app/src/main/java/barqsoft/footballscores/widget/ListWidgetProvider.java new file mode 100644 index 0000000..5fe4ed3 --- /dev/null +++ b/Football/app/src/main/java/barqsoft/footballscores/widget/ListWidgetProvider.java @@ -0,0 +1,40 @@ +package barqsoft.footballscores.widget; + +import android.app.PendingIntent; +import android.appwidget.AppWidgetManager; +import android.appwidget.AppWidgetProvider; +import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.widget.RemoteViews; + +import barqsoft.footballscores.R; + +/** + * Widgetprovider for the scores list widget + */ +public class ListWidgetProvider extends AppWidgetProvider { + + @Override + public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { + for(int widgetId : appWidgetIds) { + RemoteViews rvs = updateWidgetListView(context, widgetId); + appWidgetManager.updateAppWidget(appWidgetIds, rvs); + } + + super.onUpdate(context, appWidgetManager, appWidgetIds); + } + + private RemoteViews updateWidgetListView(Context context, int appWidgetId) { + RemoteViews rvs = new RemoteViews(context.getPackageName(), R.layout.list_widget); + + Intent serviceIntent = new Intent(context, ListWidgetService.class); + serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); + serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME))); + + rvs.setRemoteAdapter(R.id.list_widget_listView, serviceIntent); + rvs.setEmptyView(R.id.list_widget_listView, R.id.list_widget_empty_view); + + return rvs; + } +} diff --git a/Football/app/src/main/java/barqsoft/footballscores/widget/ListWidgetService.java b/Football/app/src/main/java/barqsoft/footballscores/widget/ListWidgetService.java new file mode 100644 index 0000000..92e06ce --- /dev/null +++ b/Football/app/src/main/java/barqsoft/footballscores/widget/ListWidgetService.java @@ -0,0 +1,16 @@ +package barqsoft.footballscores.widget; + +import android.annotation.TargetApi; +import android.appwidget.AppWidgetManager; +import android.content.Intent; +import android.os.Build; +import android.widget.RemoteViewsService; + +@TargetApi(Build.VERSION_CODES.HONEYCOMB) +public class ListWidgetService extends RemoteViewsService { + @Override + public RemoteViewsFactory onGetViewFactory(Intent intent) { + int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); + return new ListWidgetViewFactory(getApplicationContext(), appWidgetId); + } +} diff --git a/Football/app/src/main/java/barqsoft/footballscores/widget/ListWidgetViewFactory.java b/Football/app/src/main/java/barqsoft/footballscores/widget/ListWidgetViewFactory.java new file mode 100644 index 0000000..a22f0db --- /dev/null +++ b/Football/app/src/main/java/barqsoft/footballscores/widget/ListWidgetViewFactory.java @@ -0,0 +1,104 @@ +package barqsoft.footballscores.widget; + +import android.annotation.TargetApi; +import android.content.Context; +import android.database.Cursor; +import android.os.Build; +import android.util.Log; +import android.widget.RemoteViews; +import android.widget.RemoteViewsService; + +import barqsoft.footballscores.DatabaseContract; +import barqsoft.footballscores.R; + +@TargetApi(Build.VERSION_CODES.HONEYCOMB) +class ListWidgetViewFactory implements RemoteViewsService.RemoteViewsFactory { + + public static final String TAG = ListWidgetViewFactory.class.getSimpleName(); + + int mAppWidgetId; + Context mContext; + + Cursor mCursor; + + public ListWidgetViewFactory(Context context, int appWidgetId) { + mContext = context; + this.mAppWidgetId = appWidgetId; + } + + @Override + public void onCreate() { + // nothing to do here + } + + @Override + public void onDataSetChanged() { + if(mCursor != null) + mCursor.close(); + mCursor = mContext.getContentResolver().query(DatabaseContract.BASE_CONTENT_URI, null, null, null, null); + } + + @Override + public void onDestroy() { + if(mCursor != null) + mCursor.close(); + } + + @Override + public int getCount() { + if(mCursor == null) { + Log.d(TAG, "get Count: cursor is null!"); + return 0; + } + + return mCursor.getCount(); + } + + @Override + public RemoteViews getViewAt(int position) { + RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.list_widget_item); + mCursor.moveToPosition(position); + + String homeName = mCursor.getString(mCursor.getColumnIndex(DatabaseContract.scores_table.HOME_COL)); + String awayName = mCursor.getString(mCursor.getColumnIndex(DatabaseContract.scores_table.AWAY_COL)); + + String score; + int homeGoals = mCursor.getInt(mCursor.getColumnIndex(DatabaseContract.scores_table.HOME_GOALS_COL)); + int awayGoals = mCursor.getInt(mCursor.getColumnIndex(DatabaseContract.scores_table.AWAY_GOALS_COL)); + if(homeGoals < 0 || awayGoals < 0) + score = mContext.getString(R.string.scores, " ", " "); + else + score = mContext.getString(R.string.scores, homeGoals, awayGoals); + + + String dateString = + mCursor.getString(mCursor.getColumnIndex(DatabaseContract.scores_table.DATE_COL)) + + " " + + mCursor.getString(mCursor.getColumnIndex(DatabaseContract.scores_table.TIME_COL)); + Log.d(TAG, homeName + " " + awayName + " " + score + " " + dateString); + + rv.setTextViewText(R.id.list_widget_item_hostname, homeName); + rv.setTextViewText(R.id.list_widget_item_awayname, awayName); + rv.setTextViewText(R.id.list_widget_item_score, score); + rv.setTextViewText(R.id.list_widget_item_date, dateString); + return rv; + } + + @Override + public RemoteViews getLoadingView() { return null; } + + @Override + public int getViewTypeCount() { + return 1; + } + + @Override + public long getItemId(int position) { + return 0; + } + + @Override + public boolean hasStableIds() { + return false; + } +} \ No newline at end of file diff --git a/Football/app/src/main/res/drawable-hdpi/arsenal.png b/Football/app/src/main/res/drawable-hdpi/arsenal.png new file mode 100644 index 0000000..41e2135 Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/arsenal.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/aston_villa.png b/Football/app/src/main/res/drawable-hdpi/aston_villa.png new file mode 100644 index 0000000..4012c99 Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/aston_villa.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/burney_fc_hd_logo.png b/Football/app/src/main/res/drawable-hdpi/burney_fc_hd_logo.png new file mode 100644 index 0000000..b906be6 Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/burney_fc_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/chelsea.png b/Football/app/src/main/res/drawable-hdpi/chelsea.png new file mode 100644 index 0000000..ccc2c65 Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/chelsea.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/crystal_palace_fc.png b/Football/app/src/main/res/drawable-hdpi/crystal_palace_fc.png new file mode 100644 index 0000000..22335d8 Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/crystal_palace_fc.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/everton_fc_logo1.png b/Football/app/src/main/res/drawable-hdpi/everton_fc_logo1.png new file mode 100644 index 0000000..499e901 Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/everton_fc_logo1.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/hull_city_afc_hd_logo.png b/Football/app/src/main/res/drawable-hdpi/hull_city_afc_hd_logo.png new file mode 100644 index 0000000..9f3ea4a Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/hull_city_afc_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/ic_launcher.png b/Football/app/src/main/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000..9b79813 Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/ic_launcher.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/leicester_city_fc_hd_logo.png b/Football/app/src/main/res/drawable-hdpi/leicester_city_fc_hd_logo.png new file mode 100644 index 0000000..5ba850c Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/leicester_city_fc_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/liverpool.png b/Football/app/src/main/res/drawable-hdpi/liverpool.png new file mode 100644 index 0000000..80d17b3 Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/liverpool.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/manchester_city.png b/Football/app/src/main/res/drawable-hdpi/manchester_city.png new file mode 100644 index 0000000..ed761bc Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/manchester_city.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/manchester_united.png b/Football/app/src/main/res/drawable-hdpi/manchester_united.png new file mode 100644 index 0000000..0c98126 Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/manchester_united.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/newcastle_united.png b/Football/app/src/main/res/drawable-hdpi/newcastle_united.png new file mode 100644 index 0000000..131b966 Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/newcastle_united.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/no_icon.png b/Football/app/src/main/res/drawable-hdpi/no_icon.png new file mode 100644 index 0000000..fcccb2d Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/no_icon.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/queens_park_rangers_hd_logo.png b/Football/app/src/main/res/drawable-hdpi/queens_park_rangers_hd_logo.png new file mode 100644 index 0000000..0e2427e Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/queens_park_rangers_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/southampton_fc.png b/Football/app/src/main/res/drawable-hdpi/southampton_fc.png new file mode 100644 index 0000000..1beb4d2 Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/southampton_fc.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/stoke_city.png b/Football/app/src/main/res/drawable-hdpi/stoke_city.png new file mode 100644 index 0000000..7c2d6b6 Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/stoke_city.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/sunderland.png b/Football/app/src/main/res/drawable-hdpi/sunderland.png new file mode 100644 index 0000000..dcba2dd Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/sunderland.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/swansea_city_afc.png b/Football/app/src/main/res/drawable-hdpi/swansea_city_afc.png new file mode 100644 index 0000000..b9769f6 Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/swansea_city_afc.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/tottenham_hotspur.png b/Football/app/src/main/res/drawable-hdpi/tottenham_hotspur.png new file mode 100644 index 0000000..3f6471f Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/tottenham_hotspur.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/west_bromwich_albion_hd_logo.png b/Football/app/src/main/res/drawable-hdpi/west_bromwich_albion_hd_logo.png new file mode 100644 index 0000000..0aed96d Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/west_bromwich_albion_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-hdpi/west_ham.png b/Football/app/src/main/res/drawable-hdpi/west_ham.png new file mode 100644 index 0000000..125d45a Binary files /dev/null and b/Football/app/src/main/res/drawable-hdpi/west_ham.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/arsenal.png b/Football/app/src/main/res/drawable-mdpi/arsenal.png new file mode 100644 index 0000000..0102d3a Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/arsenal.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/aston_villa.png b/Football/app/src/main/res/drawable-mdpi/aston_villa.png new file mode 100644 index 0000000..88f80c4 Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/aston_villa.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/burney_fc_hd_logo.png b/Football/app/src/main/res/drawable-mdpi/burney_fc_hd_logo.png new file mode 100644 index 0000000..4ca287d Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/burney_fc_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/chelsea.png b/Football/app/src/main/res/drawable-mdpi/chelsea.png new file mode 100644 index 0000000..f627558 Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/chelsea.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/crystal_palace_fc.png b/Football/app/src/main/res/drawable-mdpi/crystal_palace_fc.png new file mode 100644 index 0000000..4f71627 Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/crystal_palace_fc.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/everton_fc_logo1.png b/Football/app/src/main/res/drawable-mdpi/everton_fc_logo1.png new file mode 100644 index 0000000..5366da2 Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/everton_fc_logo1.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/hull_city_afc_hd_logo.png b/Football/app/src/main/res/drawable-mdpi/hull_city_afc_hd_logo.png new file mode 100644 index 0000000..16f5b35 Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/hull_city_afc_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/ic_launcher.png b/Football/app/src/main/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000..0d8d38b Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/ic_launcher.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/leicester_city_fc_hd_logo.png b/Football/app/src/main/res/drawable-mdpi/leicester_city_fc_hd_logo.png new file mode 100644 index 0000000..d788234 Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/leicester_city_fc_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/liverpool.png b/Football/app/src/main/res/drawable-mdpi/liverpool.png new file mode 100644 index 0000000..dfa3a4c Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/liverpool.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/manchester_city.png b/Football/app/src/main/res/drawable-mdpi/manchester_city.png new file mode 100644 index 0000000..db565a2 Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/manchester_city.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/manchester_united.png b/Football/app/src/main/res/drawable-mdpi/manchester_united.png new file mode 100644 index 0000000..c164e13 Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/manchester_united.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/newcastle_united.png b/Football/app/src/main/res/drawable-mdpi/newcastle_united.png new file mode 100644 index 0000000..466e8c6 Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/newcastle_united.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/no_icon.png b/Football/app/src/main/res/drawable-mdpi/no_icon.png new file mode 100644 index 0000000..6c62d60 Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/no_icon.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/queens_park_rangers_hd_logo.png b/Football/app/src/main/res/drawable-mdpi/queens_park_rangers_hd_logo.png new file mode 100644 index 0000000..199178d Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/queens_park_rangers_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/southampton_fc.png b/Football/app/src/main/res/drawable-mdpi/southampton_fc.png new file mode 100644 index 0000000..d40b940 Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/southampton_fc.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/stoke_city.png b/Football/app/src/main/res/drawable-mdpi/stoke_city.png new file mode 100644 index 0000000..360a2cc Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/stoke_city.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/sunderland.png b/Football/app/src/main/res/drawable-mdpi/sunderland.png new file mode 100644 index 0000000..09e14a6 Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/sunderland.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/swansea_city_afc.png b/Football/app/src/main/res/drawable-mdpi/swansea_city_afc.png new file mode 100644 index 0000000..9888faa Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/swansea_city_afc.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/tottenham_hotspur.png b/Football/app/src/main/res/drawable-mdpi/tottenham_hotspur.png new file mode 100644 index 0000000..bbdde1d Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/tottenham_hotspur.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/west_bromwich_albion_hd_logo.png b/Football/app/src/main/res/drawable-mdpi/west_bromwich_albion_hd_logo.png new file mode 100644 index 0000000..49628a8 Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/west_bromwich_albion_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-mdpi/west_ham.png b/Football/app/src/main/res/drawable-mdpi/west_ham.png new file mode 100644 index 0000000..c5eec2d Binary files /dev/null and b/Football/app/src/main/res/drawable-mdpi/west_ham.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/arsenal.png b/Football/app/src/main/res/drawable-xhdpi/arsenal.png new file mode 100644 index 0000000..99cf502 Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/arsenal.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/aston_villa.png b/Football/app/src/main/res/drawable-xhdpi/aston_villa.png new file mode 100644 index 0000000..af1507e Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/aston_villa.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/burney_fc_hd_logo.png b/Football/app/src/main/res/drawable-xhdpi/burney_fc_hd_logo.png new file mode 100644 index 0000000..dc31961 Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/burney_fc_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/chelsea.png b/Football/app/src/main/res/drawable-xhdpi/chelsea.png new file mode 100644 index 0000000..1f7a758 Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/chelsea.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/crystal_palace_fc.png b/Football/app/src/main/res/drawable-xhdpi/crystal_palace_fc.png new file mode 100644 index 0000000..88c7125 Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/crystal_palace_fc.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/everton_fc_logo1.png b/Football/app/src/main/res/drawable-xhdpi/everton_fc_logo1.png new file mode 100644 index 0000000..443938a Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/everton_fc_logo1.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/hull_city_afc_hd_logo.png b/Football/app/src/main/res/drawable-xhdpi/hull_city_afc_hd_logo.png new file mode 100644 index 0000000..91e4b53 Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/hull_city_afc_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/ic_launcher.png b/Football/app/src/main/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000..a4458f6 Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/ic_launcher.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/leicester_city_fc_hd_logo.png b/Football/app/src/main/res/drawable-xhdpi/leicester_city_fc_hd_logo.png new file mode 100644 index 0000000..c460897 Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/leicester_city_fc_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/liverpool.png b/Football/app/src/main/res/drawable-xhdpi/liverpool.png new file mode 100644 index 0000000..7377483 Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/liverpool.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/manchester_city.png b/Football/app/src/main/res/drawable-xhdpi/manchester_city.png new file mode 100644 index 0000000..b7ca9e4 Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/manchester_city.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/manchester_united.png b/Football/app/src/main/res/drawable-xhdpi/manchester_united.png new file mode 100644 index 0000000..708ee80 Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/manchester_united.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/newcastle_united.png b/Football/app/src/main/res/drawable-xhdpi/newcastle_united.png new file mode 100644 index 0000000..0591150 Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/newcastle_united.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/no_icon.png b/Football/app/src/main/res/drawable-xhdpi/no_icon.png new file mode 100644 index 0000000..69446e4 Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/no_icon.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/queens_park_rangers_hd_logo.png b/Football/app/src/main/res/drawable-xhdpi/queens_park_rangers_hd_logo.png new file mode 100644 index 0000000..167212d Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/queens_park_rangers_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/southampton_fc.png b/Football/app/src/main/res/drawable-xhdpi/southampton_fc.png new file mode 100644 index 0000000..22070c8 Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/southampton_fc.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/stoke_city.png b/Football/app/src/main/res/drawable-xhdpi/stoke_city.png new file mode 100644 index 0000000..36e8bf5 Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/stoke_city.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/sunderland.png b/Football/app/src/main/res/drawable-xhdpi/sunderland.png new file mode 100644 index 0000000..291bca5 Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/sunderland.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/swansea_city_afc.png b/Football/app/src/main/res/drawable-xhdpi/swansea_city_afc.png new file mode 100644 index 0000000..329e5da Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/swansea_city_afc.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/tottenham_hotspur.png b/Football/app/src/main/res/drawable-xhdpi/tottenham_hotspur.png new file mode 100644 index 0000000..129802b Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/tottenham_hotspur.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/west_bromwich_albion_hd_logo.png b/Football/app/src/main/res/drawable-xhdpi/west_bromwich_albion_hd_logo.png new file mode 100644 index 0000000..86499d9 Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/west_bromwich_albion_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-xhdpi/west_ham.png b/Football/app/src/main/res/drawable-xhdpi/west_ham.png new file mode 100644 index 0000000..7570e89 Binary files /dev/null and b/Football/app/src/main/res/drawable-xhdpi/west_ham.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/arsenal.png b/Football/app/src/main/res/drawable-xxhdpi/arsenal.png new file mode 100644 index 0000000..60d11d7 Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/arsenal.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/aston_villa.png b/Football/app/src/main/res/drawable-xxhdpi/aston_villa.png new file mode 100644 index 0000000..eb1e428 Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/aston_villa.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/burney_fc_hd_logo.png b/Football/app/src/main/res/drawable-xxhdpi/burney_fc_hd_logo.png new file mode 100644 index 0000000..6ae9917 Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/burney_fc_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/chelsea.png b/Football/app/src/main/res/drawable-xxhdpi/chelsea.png new file mode 100644 index 0000000..bacaa25 Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/chelsea.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/crystal_palace_fc.png b/Football/app/src/main/res/drawable-xxhdpi/crystal_palace_fc.png new file mode 100644 index 0000000..382e262 Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/crystal_palace_fc.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/everton_fc_logo1.png b/Football/app/src/main/res/drawable-xxhdpi/everton_fc_logo1.png new file mode 100644 index 0000000..910a26d Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/everton_fc_logo1.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/hull_city_afc_hd_logo.png b/Football/app/src/main/res/drawable-xxhdpi/hull_city_afc_hd_logo.png new file mode 100644 index 0000000..9d3bf5e Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/hull_city_afc_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/ic_launcher.png b/Football/app/src/main/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..5cae0d2 Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/leicester_city_fc_hd_logo.png b/Football/app/src/main/res/drawable-xxhdpi/leicester_city_fc_hd_logo.png new file mode 100644 index 0000000..88bbb31 Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/leicester_city_fc_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/liverpool.png b/Football/app/src/main/res/drawable-xxhdpi/liverpool.png new file mode 100644 index 0000000..a4b46b6 Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/liverpool.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/manchester_city.png b/Football/app/src/main/res/drawable-xxhdpi/manchester_city.png new file mode 100644 index 0000000..1bb8425 Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/manchester_city.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/manchester_united.png b/Football/app/src/main/res/drawable-xxhdpi/manchester_united.png new file mode 100644 index 0000000..5d4d7f5 Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/manchester_united.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/newcastle_united.png b/Football/app/src/main/res/drawable-xxhdpi/newcastle_united.png new file mode 100644 index 0000000..31032bc Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/newcastle_united.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/no_icon.png b/Football/app/src/main/res/drawable-xxhdpi/no_icon.png new file mode 100644 index 0000000..3f4ea49 Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/no_icon.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/queens_park_rangers_hd_logo.png b/Football/app/src/main/res/drawable-xxhdpi/queens_park_rangers_hd_logo.png new file mode 100644 index 0000000..800cc48 Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/queens_park_rangers_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/southampton_fc.png b/Football/app/src/main/res/drawable-xxhdpi/southampton_fc.png new file mode 100644 index 0000000..e63ab3e Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/southampton_fc.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/stoke_city.png b/Football/app/src/main/res/drawable-xxhdpi/stoke_city.png new file mode 100644 index 0000000..cf92d9a Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/stoke_city.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/sunderland.png b/Football/app/src/main/res/drawable-xxhdpi/sunderland.png new file mode 100644 index 0000000..99ae2e2 Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/sunderland.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/swansea_city_afc.png b/Football/app/src/main/res/drawable-xxhdpi/swansea_city_afc.png new file mode 100644 index 0000000..5ea0071 Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/swansea_city_afc.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/tottenham_hotspur.png b/Football/app/src/main/res/drawable-xxhdpi/tottenham_hotspur.png new file mode 100644 index 0000000..35452ad Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/tottenham_hotspur.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/west_bromwich_albion_hd_logo.png b/Football/app/src/main/res/drawable-xxhdpi/west_bromwich_albion_hd_logo.png new file mode 100644 index 0000000..7574644 Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/west_bromwich_albion_hd_logo.png differ diff --git a/Football/app/src/main/res/drawable-xxhdpi/west_ham.png b/Football/app/src/main/res/drawable-xxhdpi/west_ham.png new file mode 100644 index 0000000..5e04759 Binary files /dev/null and b/Football/app/src/main/res/drawable-xxhdpi/west_ham.png differ diff --git a/Football/app/src/main/res/drawable/list_item.xml b/Football/app/src/main/res/drawable/list_item.xml new file mode 100644 index 0000000..a2b3001 --- /dev/null +++ b/Football/app/src/main/res/drawable/list_item.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Football/app/src/main/res/layout/activity_about.xml b/Football/app/src/main/res/layout/activity_about.xml new file mode 100644 index 0000000..c776ed6 --- /dev/null +++ b/Football/app/src/main/res/layout/activity_about.xml @@ -0,0 +1,7 @@ + diff --git a/Football/app/src/main/res/layout/activity_main.xml b/Football/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..120e794 --- /dev/null +++ b/Football/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,8 @@ + diff --git a/Football/app/src/main/res/layout/detail_fragment.xml b/Football/app/src/main/res/layout/detail_fragment.xml new file mode 100644 index 0000000..c508047 --- /dev/null +++ b/Football/app/src/main/res/layout/detail_fragment.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + +