From 5f4ed7d284444b8791b93bcd63be4787b539dde6 Mon Sep 17 00:00:00 2001 From: Mohamed Alouane Date: Wed, 18 Feb 2015 18:30:34 +0000 Subject: [PATCH 1/5] add Flashcard exercise --- app/src/main/AndroidManifest.xml | 2 +- .../kanshu/kanshu/DevelopmentActivity.java | 2 +- .../kanshu/ExerciseOptionsListFragment.java | 73 ++++++++ .../kanshu/FlashCardExerciseActivity.java | 158 ++++++++++++++++++ .../kanshu/Model/FlashcardExercise.java | 42 +++++ .../kanshu/Model/FlashcardExerciseOption.java | 41 +++++ .../widget/FlashCardExerciseAdapter.java | 82 +++++++++ .../main/res/layout/activity_development.xml | 16 +- .../layout/fragment_flashcard_exercise.xml | 46 +++++ .../layout/row_falshcard_exercise_options.xml | 53 ++++++ 10 files changed, 505 insertions(+), 10 deletions(-) create mode 100644 app/src/main/java/com/kanshu/kanshu/ExerciseOptionsListFragment.java create mode 100644 app/src/main/java/com/kanshu/kanshu/FlashCardExerciseActivity.java create mode 100644 app/src/main/java/com/kanshu/kanshu/Model/FlashcardExercise.java create mode 100644 app/src/main/java/com/kanshu/kanshu/Model/FlashcardExerciseOption.java create mode 100644 app/src/main/java/com/kanshu/kanshu/widget/FlashCardExerciseAdapter.java create mode 100644 app/src/main/res/layout/fragment_flashcard_exercise.xml create mode 100644 app/src/main/res/layout/row_falshcard_exercise_options.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 24f35b7..e5c3fe9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -90,4 +90,4 @@ - + \ No newline at end of file diff --git a/app/src/main/java/com/kanshu/kanshu/DevelopmentActivity.java b/app/src/main/java/com/kanshu/kanshu/DevelopmentActivity.java index 7b71d8c..f1a8eed 100644 --- a/app/src/main/java/com/kanshu/kanshu/DevelopmentActivity.java +++ b/app/src/main/java/com/kanshu/kanshu/DevelopmentActivity.java @@ -50,4 +50,4 @@ public void onFeedbackActivity(View view) { public void onSettingsActivity(View view) { startActivity(new Intent(this, SettingsActivity.class)); } -} +} \ No newline at end of file diff --git a/app/src/main/java/com/kanshu/kanshu/ExerciseOptionsListFragment.java b/app/src/main/java/com/kanshu/kanshu/ExerciseOptionsListFragment.java new file mode 100644 index 0000000..6085be9 --- /dev/null +++ b/app/src/main/java/com/kanshu/kanshu/ExerciseOptionsListFragment.java @@ -0,0 +1,73 @@ +package com.kanshu.kanshu; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.kanshu.kanshu.model.FlashcardExerciseOption; +import com.kanshu.kanshu.widget.FlashCardExerciseAdapter; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by alouanemed on 17-02-2015. + */ + + +public class ExerciseOptionsListFragment extends Fragment { + private RecyclerView mRecyclerView; + private RecyclerView.Adapter mAdapter; + private LinearLayoutManager mLayoutManager; + /** + * The fragment argument representing the section number for this + * fragment. + */ + private static final String ARG_SECTION_NUMBER = "section_number"; + + /** + * Returns a new instance of this fragment for the given section + * number. + */ + public static ExerciseOptionsListFragment newInstance(int sectionNumber) { + ExerciseOptionsListFragment fragment = new ExerciseOptionsListFragment(); + Bundle args = new Bundle(); + args.putInt(ARG_SECTION_NUMBER, sectionNumber); + fragment.setArguments(args); + return fragment; + } + + public ExerciseOptionsListFragment() {} + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_flashcard_exercise, container, false); + mRecyclerView = (RecyclerView) rootView.findViewById(R.id.my_recycler_view); + // use a linear layout manager + mLayoutManager = new LinearLayoutManager(getActivity()); + mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); + mRecyclerView.setLayoutManager(mLayoutManager); + + //@todo use the real data to replace dummy data + List mFlashcardExerciseOptions = new ArrayList(); + mFlashcardExerciseOptions.add(new FlashcardExerciseOption("Airplane",false)); + mFlashcardExerciseOptions.add(new FlashcardExerciseOption("You",false)); + mFlashcardExerciseOptions.add(new FlashcardExerciseOption("Car",true)); + mFlashcardExerciseOptions.add(new FlashcardExerciseOption("Person",false)); + mFlashcardExerciseOptions.add(new FlashcardExerciseOption("Asm",false)); + mFlashcardExerciseOptions.add(new FlashcardExerciseOption("Git",false)); + mFlashcardExerciseOptions.add(new FlashcardExerciseOption("Afourer",false)); + + + // specify an adapter + mAdapter = new FlashCardExerciseAdapter(mFlashcardExerciseOptions); + mRecyclerView.setAdapter(mAdapter); + return rootView; + } + +} diff --git a/app/src/main/java/com/kanshu/kanshu/FlashCardExerciseActivity.java b/app/src/main/java/com/kanshu/kanshu/FlashCardExerciseActivity.java new file mode 100644 index 0000000..c8513b5 --- /dev/null +++ b/app/src/main/java/com/kanshu/kanshu/FlashCardExerciseActivity.java @@ -0,0 +1,158 @@ +package com.kanshu.kanshu; + +import android.os.Bundle; +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.support.v4.widget.DrawerLayout; +import android.support.v7.widget.Toolbar; +import android.view.Menu; +import android.view.MenuItem; + +import com.kanshu.kanshu.model.User; + + +/** + * Created by alouanemed on 17-02-2015. + */ +public class FlashCardExerciseActivity extends BaseActivity + implements NavigationDrawerFragment.NavigationDrawerCallbacks, + NavigationDrawerFragment.NavigationDrawerData { + + /** + * Fragment managing the behaviors, interactions and presentation of the navigation drawer. + */ + private NavigationDrawerFragment mNavigationDrawerFragment; + private SlidingTabLayout mSlidingTabLayout; + private FlashCardPagerAdapter mFlashCardPagerAdapter; + private ViewPager mViewPager; + private Toolbar mToolbar; + private User mCurrentUser; + + /** + * Used to store the last screen title. For use in {@link #restoreActionBar()}. + */ + private CharSequence mTitle; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + if (getIntent().hasExtra("user")) { + mCurrentUser = getIntent().getExtras().getParcelable("user"); + } + if (mCurrentUser == null) { + mCurrentUser = new User("name", "level"); + } + + //set custom toolbar + mToolbar = (Toolbar) findViewById(R.id.toolbar); + if (mToolbar != null) { + setSupportActionBar(mToolbar); + } + + mNavigationDrawerFragment = (NavigationDrawerFragment) + getSupportFragmentManager().findFragmentById(R.id.navigation_drawer); + mTitle = getTitle(); + + // Set up the drawer. + mNavigationDrawerFragment.setUp( + R.id.navigation_drawer, + (DrawerLayout) findViewById(R.id.drawer_layout)); + + //Set up the pager + mFlashCardPagerAdapter = + new FlashCardPagerAdapter( + getSupportFragmentManager()); + mViewPager = (ViewPager) findViewById(R.id.pager); + mViewPager.setAdapter(mFlashCardPagerAdapter); + mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs); + mSlidingTabLayout.setSelectedIndicatorColors(getResources().getColor(R.color.white)); + mSlidingTabLayout.setViewPager(mViewPager); + } + + @Override + public void onNavigationDrawerItemSelected(int position) { + } + + public void onSectionAttached(int number) { + switch (number) { + case 1: + mTitle = getString(R.string.title_section1); + break; + case 2: + mTitle = getString(R.string.title_section2); + break; + case 3: + mTitle = getString(R.string.title_section3); + break; + } + } + + public void restoreActionBar() { + mToolbar.setTitle(mTitle); + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + if (!mNavigationDrawerFragment.isDrawerOpen()) { + // Only show items in the action bar relevant to this screen + // if the drawer is not showing. Otherwise, let the drawer + // decide what to show in the action bar. + getMenuInflater().inflate(R.menu.global, menu); + restoreActionBar(); + return true; + } + return super.onCreateOptionsMenu(menu); + } + + @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); + } + + @Override + public User getCurrentUser() { + return mCurrentUser; + } + + + public class FlashCardPagerAdapter extends FragmentStatePagerAdapter { + + //the list of titles of pages + private String[] pageTitles = {"Flashcard Exercise"}; + + public FlashCardPagerAdapter(FragmentManager fm) { + super(fm); + } + + @Override + public Fragment getItem(int i) { + Fragment fragment = new ExerciseOptionsListFragment(); + return fragment; + } + + @Override + public int getCount() { + return pageTitles.length; + } + + @Override + public CharSequence getPageTitle(int position) { + return pageTitles[position]; + } + } + +} diff --git a/app/src/main/java/com/kanshu/kanshu/Model/FlashcardExercise.java b/app/src/main/java/com/kanshu/kanshu/Model/FlashcardExercise.java new file mode 100644 index 0000000..31e0689 --- /dev/null +++ b/app/src/main/java/com/kanshu/kanshu/Model/FlashcardExercise.java @@ -0,0 +1,42 @@ +package com.kanshu.kanshu.model; + +import java.util.ArrayList; + +/** + * Created by alouanemed on 18-02-2015. + */ +public class FlashcardExercise { + private String ChineseWord; + private String ChineseWordSpelling; + private ArrayList options; + + public FlashcardExercise(String chineseWord, String chineseWordSpelling, ArrayList options) { + ChineseWord = chineseWord; + ChineseWordSpelling = chineseWordSpelling; + this.options = options; + } + + public String getChineseWord() { + return ChineseWord; + } + + public void setChineseWord(String chineseWord) { + ChineseWord = chineseWord; + } + + public String getChineseWordSpelling() { + return ChineseWordSpelling; + } + + public void setChineseWordSpelling(String chineseWordSpelling) { + ChineseWordSpelling = chineseWordSpelling; + } + + public ArrayList getOptions() { + return options; + } + + public void setOptions(ArrayList options) { + this.options = options; + } +} diff --git a/app/src/main/java/com/kanshu/kanshu/Model/FlashcardExerciseOption.java b/app/src/main/java/com/kanshu/kanshu/Model/FlashcardExerciseOption.java new file mode 100644 index 0000000..3cebc99 --- /dev/null +++ b/app/src/main/java/com/kanshu/kanshu/Model/FlashcardExerciseOption.java @@ -0,0 +1,41 @@ +package com.kanshu.kanshu.model; + +/** + * Created by alouanemed on 17-02-2015. + */ +public class FlashcardExerciseOption { + private static int nb = 0; + private String Title; + private Boolean correct_answer; + + + public FlashcardExerciseOption(String title, Boolean correct_answer) { + Title = title; + this.correct_answer = correct_answer; + nb++; + } + + public int getNb() { + return nb; + } + + public void setNb(int nb) { + this.nb = nb; + } + + public String getTitle() { + return Title; + } + + public void setTitle(String title) { + Title = title; + } + + public Boolean getCorrect_answer() { + return correct_answer; + } + + public void setCorrect_answer(Boolean correct_answer) { + this.correct_answer = correct_answer; + } +} diff --git a/app/src/main/java/com/kanshu/kanshu/widget/FlashCardExerciseAdapter.java b/app/src/main/java/com/kanshu/kanshu/widget/FlashCardExerciseAdapter.java new file mode 100644 index 0000000..7b4c773 --- /dev/null +++ b/app/src/main/java/com/kanshu/kanshu/widget/FlashCardExerciseAdapter.java @@ -0,0 +1,82 @@ +package com.kanshu.kanshu.widget; + +import android.support.v7.widget.RecyclerView; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import com.kanshu.kanshu.R; +import com.kanshu.kanshu.model.FlashcardExerciseOption; + +import java.util.List; + + +/** + * Created by alouanemed on 17-02-2015. + */ +public class FlashCardExerciseAdapter extends RecyclerView.Adapter { + + private List flashcardExerciseOptionsList; + + // Provide a reference to the views for each data item + // Complex data items may need more than one view per item, and + // you provide access to all the views for a data item in a view holder + public class FlashCardExerciseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ + public TextView optionNbTV; + public TextView optionTitleTV; + public ImageView deleteBtn; + + public FlashCardExerciseViewHolder(View v) { + super(v); + optionNbTV = (TextView) v.findViewById(R.id.option_nb); + optionTitleTV = (TextView) v.findViewById(R.id.option_title); + deleteBtn = (ImageView) v.findViewById(R.id.option_delete); + } + + @Override + public void onClick(View view) { + Log.d("FlashCardExerciseAdapter", "onClick " + getPosition() ); + } + } + + + public FlashCardExerciseAdapter(List lst) { + flashcardExerciseOptionsList = lst; + } + + // Create new views (invoked by the layout manager) + @Override + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_falshcard_exercise_options, parent, false); + + RecyclerView.ViewHolder vh = new FlashCardExerciseViewHolder(v); + return vh; + } + + @Override + public int getItemViewType(int position) { + //@todo replace this with a real get item new type method based on the real data + //right now I would just make every 5th card an indicator + if (position % 5 == 0) { + return 1; + } else { + return 0; + } + } + + // Replace the contents of a view (invoked by the layout manager) + @Override + public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { + FlashcardExerciseOption _Flashcard_ExerciseOption = flashcardExerciseOptionsList.get(position); + //@todo set the real data here. + + } + + @Override + public int getItemCount() { + return flashcardExerciseOptionsList.size(); + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_development.xml b/app/src/main/res/layout/activity_development.xml index fcaf6b1..02621bc 100644 --- a/app/src/main/res/layout/activity_development.xml +++ b/app/src/main/res/layout/activity_development.xml @@ -1,12 +1,12 @@ + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:paddingLeft="@dimen/activity_horizontal_margin" + android:paddingRight="@dimen/activity_horizontal_margin" + android:paddingTop="@dimen/activity_vertical_margin" + android:paddingBottom="@dimen/activity_vertical_margin" + tools:context="com.kanshu.kanshu.DevelopmentActivity"> + + + + + + + + + + + diff --git a/app/src/main/res/layout/row_falshcard_exercise_options.xml b/app/src/main/res/layout/row_falshcard_exercise_options.xml new file mode 100644 index 0000000..895f60e --- /dev/null +++ b/app/src/main/res/layout/row_falshcard_exercise_options.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + \ No newline at end of file From ecc8e5f0c5ea862d3926a6c5190f2fdab8ae97db Mon Sep 17 00:00:00 2001 From: Mohamed Alouane Date: Fri, 20 Feb 2015 11:11:07 +0000 Subject: [PATCH 2/5] indicate the wrong and the correct answer --- app/src/main/ic_check_white-web.png | Bin 0 -> 5354 bytes .../kanshu/ExerciseOptionsListFragment.java | 35 +++++-- .../kanshu/FlashCardExerciseAdapter.java | 95 ++++++++++++++++++ .../kanshu/Model/FlashcardExerciseOption.java | 16 +-- .../main/res/drawable-hdpi/ic_check_white.png | Bin 0 -> 1299 bytes .../main/res/drawable-mdpi/ic_check_white.png | Bin 0 -> 805 bytes .../res/drawable-xhdpi/ic_check_white.png | Bin 0 -> 2046 bytes .../res/drawable-xxhdpi/ic_check_white.png | Bin 0 -> 2955 bytes 8 files changed, 133 insertions(+), 13 deletions(-) create mode 100644 app/src/main/ic_check_white-web.png create mode 100644 app/src/main/java/com/kanshu/kanshu/FlashCardExerciseAdapter.java create mode 100644 app/src/main/res/drawable-hdpi/ic_check_white.png create mode 100644 app/src/main/res/drawable-mdpi/ic_check_white.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_check_white.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_check_white.png diff --git a/app/src/main/ic_check_white-web.png b/app/src/main/ic_check_white-web.png new file mode 100644 index 0000000000000000000000000000000000000000..4ac93528194ced2a3208ed5b98015ea2fbb9e059 GIT binary patch literal 5354 zcmd5=d010d7Jr05SOo&t7K+6N7ECIqY_r4&5)tRr~H}l8j`|>3@x%Zym`Tfp0 z_uhAOi|2Y>txvTO1kv5NVeM7~A%U+XL_-~X^f4a|BZ%SkjcZqVGaI^|cBP#`&sXj% zy82TJ`)dP(+@;SRa?}hK`NwR~e>2n2d$rxJb4TaB(Q`8h`C_}d_}GGZ>Wz0*&#P?u zY98h9$2RTSpIEtR^Ok=c89sgQg7FP%h!J(p&Fsh~e0kg9%+5-OhnXyfYt9RKOwo;H zPx`aVer}OL5dR-9|L;D}uJz~XsVmlEU!)h2fl1V!{flp+au{csxDH6mhAIKD)x zi<(#|R%2PTsuq7TqJgNGA&5RgazhX^gv>?|H)uoH(1su?zy>6OHe{^FNUkYvrVgB! zWThxhipyqPjn=3gkj$}REtj69)f`r=Mw2CD^?9aR@y%tjsPTh5O5&49cl{kTi**=5 z*q-$4t#)5>ycU*U*Jeji6uacqzj3=>#fKK8-XGY^Yu}U1u?ii_=-5#>bcm!u_$7e2 zL1g*}fB>NY6U0O!aFP)>s%@8jMrkQOvN~ShCi+0vPWha;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x=6jo4*2UQiX>T%}RceER44(mQBx`l6qW{4KzJtS8;so3Ss<)9l|X0vy2< zV<#9O!D^hv!d!mN52Fs!Hro29OZ%`BvQl{^&DE;W7b`?V;YB|z?T`V;xli!I8`a^O z1N(V*z_Ws@(O#v7xKNz6Fy0-F*uNhkxe@BKl?et5LRq*(ps;KJN$}|eQ0U&{)68IA zb@eqaevR)eHV*Tmgq~d+y#vj$W~~o%IS)p{M>B2+SaIqT5yAwjeR6HyY!Ypr^ea2NEIyem|9I@RePj>0WH`51&mR#{g ze!i6=7JDtO*xS1YhDe|!vk?FnKm)L0*oX=&4TJ=32pQUtn^vT~tOQ)ZT!M> K?X}gk#D4;-XTkOW literal 0 HcmV?d00001 diff --git a/app/src/main/java/com/kanshu/kanshu/ExerciseOptionsListFragment.java b/app/src/main/java/com/kanshu/kanshu/ExerciseOptionsListFragment.java index 6085be9..c68c693 100644 --- a/app/src/main/java/com/kanshu/kanshu/ExerciseOptionsListFragment.java +++ b/app/src/main/java/com/kanshu/kanshu/ExerciseOptionsListFragment.java @@ -9,11 +9,13 @@ import android.view.ViewGroup; import com.kanshu.kanshu.model.FlashcardExerciseOption; -import com.kanshu.kanshu.widget.FlashCardExerciseAdapter; +import com.kanshu.kanshu.widget.SimpleDividerItemDecoration; import java.util.ArrayList; import java.util.List; +import com.kanshu.kanshu.FlashCardExerciseAdapter.OnItemClickListener; + /** * Created by alouanemed on 17-02-2015. */ @@ -48,13 +50,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_flashcard_exercise, container, false); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.my_recycler_view); - // use a linear layout manager - mLayoutManager = new LinearLayoutManager(getActivity()); - mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); - mRecyclerView.setLayoutManager(mLayoutManager); + mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity())); + + LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); + layoutManager.setOrientation(LinearLayoutManager.VERTICAL); + mRecyclerView.setHasFixedSize(true); + mRecyclerView.setLayoutManager(layoutManager); //@todo use the real data to replace dummy data - List mFlashcardExerciseOptions = new ArrayList(); + final List mFlashcardExerciseOptions = new ArrayList(); mFlashcardExerciseOptions.add(new FlashcardExerciseOption("Airplane",false)); mFlashcardExerciseOptions.add(new FlashcardExerciseOption("You",false)); mFlashcardExerciseOptions.add(new FlashcardExerciseOption("Car",true)); @@ -67,6 +71,25 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, // specify an adapter mAdapter = new FlashCardExerciseAdapter(mFlashcardExerciseOptions); mRecyclerView.setAdapter(mAdapter); + + ((FlashCardExerciseAdapter)mAdapter).SetOnItemClickListener(new OnItemClickListener() { + + @Override + public void onItemClick(View v , int position) { + System.out.println("clicked pos :>" + position); + FlashCardExerciseAdapter.ViewHolder holder = (FlashCardExerciseAdapter.ViewHolder )(v.getTag()); + if (mFlashcardExerciseOptions.get(position).isCorrect_answer()){ + //holder.correctOptionIV.setVisibility(View.VISIBLE); + //holder.wrongOptionIV.setVisibility(View.GONE); + v.setBackgroundColor(getResources().getColor(R.color.correct_answer_green)); + }else{ + v.setBackgroundColor(getResources().getColor(R.color.primary_light_red)); + //holder.wrongOptionIV.setVisibility(View.VISIBLE); + //holder.correctOptionIV.setVisibility(View.GONE); + } + + } + }); return rootView; } diff --git a/app/src/main/java/com/kanshu/kanshu/FlashCardExerciseAdapter.java b/app/src/main/java/com/kanshu/kanshu/FlashCardExerciseAdapter.java new file mode 100644 index 0000000..1e71dc9 --- /dev/null +++ b/app/src/main/java/com/kanshu/kanshu/FlashCardExerciseAdapter.java @@ -0,0 +1,95 @@ +package com.kanshu.kanshu; + +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import com.kanshu.kanshu.model.FlashcardExerciseOption; + +import java.util.List; + + +/** + * Created by alouanemed on 17-02-2015. + */ + +public class FlashCardExerciseAdapter extends RecyclerView.Adapter { + + private List flashcardExerciseOptionsList; + OnItemClickListener mItemClickListener; + + // Provide a reference to the views for each data item + // Complex data items may need more than one view per item, and + // you provide access to all the views for a data item in a view holder + public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ + public TextView optionNbTV; + public TextView optionTitleTV; + public ImageView wrongOptionIV; + public ImageView correctOptionIV; + + public ViewHolder(View v) { + super(v); + optionNbTV = (TextView) v.findViewById(R.id.option_nb); + optionTitleTV = (TextView) v.findViewById(R.id.option_title); + wrongOptionIV = (ImageView) v.findViewById(R.id.option_wrong); + correctOptionIV = (ImageView) v.findViewById(R.id.option_correct); + v.setOnClickListener(this); + } + + @Override + public void onClick(View view) { + if (mItemClickListener != null) { + mItemClickListener.onItemClick(view, getPosition()); + } + } + } + public interface OnItemClickListener { + public void onItemClick(View view , int position); + } + + public void SetOnItemClickListener(final OnItemClickListener mItemClickListener) { + this.mItemClickListener = mItemClickListener; + } + + + public FlashCardExerciseAdapter(List lst) { + flashcardExerciseOptionsList = lst; + } + + // Create new views (invoked by the layout manager) + @Override + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_falshcard_exercise_options, parent, false); + return new ViewHolder(v); + + } + + @Override + public int getItemViewType(int position) { + //@todo replace this with a real get item new type method based on the real data + //right now I would just make every 5th card an indicator + if (position % 5 == 0) { + return 1; + } else { + return 0; + } + } + + // Replace the contents of a view (invoked by the layout manager) + @Override + public void onBindViewHolder(ViewHolder holder, int position) { + FlashcardExerciseOption _item = flashcardExerciseOptionsList.get(position); + //@todo set the real data here. + holder.optionNbTV.setText(_item.getNumber()+"."); + holder.optionTitleTV.setText(_item.getTitle()); + + } + + @Override + public int getItemCount() { + return flashcardExerciseOptionsList.size(); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/kanshu/kanshu/Model/FlashcardExerciseOption.java b/app/src/main/java/com/kanshu/kanshu/Model/FlashcardExerciseOption.java index 3cebc99..25f1928 100644 --- a/app/src/main/java/com/kanshu/kanshu/Model/FlashcardExerciseOption.java +++ b/app/src/main/java/com/kanshu/kanshu/Model/FlashcardExerciseOption.java @@ -4,7 +4,8 @@ * Created by alouanemed on 17-02-2015. */ public class FlashcardExerciseOption { - private static int nb = 0; + private static int count_ = 0; + private int number ; private String Title; private Boolean correct_answer; @@ -12,15 +13,16 @@ public class FlashcardExerciseOption { public FlashcardExerciseOption(String title, Boolean correct_answer) { Title = title; this.correct_answer = correct_answer; - nb++; + count_++; + this.number = count_; } - public int getNb() { - return nb; + public int getNumber() { + return number; } - public void setNb(int nb) { - this.nb = nb; + public void setNumber(int nb) { + this.number = nb; } public String getTitle() { @@ -31,7 +33,7 @@ public void setTitle(String title) { Title = title; } - public Boolean getCorrect_answer() { + public Boolean isCorrect_answer() { return correct_answer; } diff --git a/app/src/main/res/drawable-hdpi/ic_check_white.png b/app/src/main/res/drawable-hdpi/ic_check_white.png new file mode 100644 index 0000000000000000000000000000000000000000..91d45e8566d74ff37f49600b1f3ebd72260d5d47 GIT binary patch literal 1299 zcmV+u1?>8XP)Xqk1QB8>tyd&y zuqY~_x>CfVsMqoR(r=P+bFaBGbI!TvHs?#e&CH#dbHDkW@BGg1{B9=W;o;%o;o;%o z;gK|yQvJXw;9{^2+yWj1Pl8S01+s~+$$Oi@wO|c6S-zvMi82_R09J!5!JWMM>)=E1 z9rzLa3jQL$@-=zy0eB5O0qy`-fOEj{;Gn)BP$jq#ya;xx((#^AwgDWQR#Ap?N}K|J zfWMV~$anTI8W(^SX%S~WxDUJyzTu7hF(A+%es?=~3)~CNbJ=`HfiuBl;4|=>vIqIC zR`4)b1&(ye%rTfU8s{06JY>qvk}-pDtGW0+?D7m$7xkYaazF74hbYZTd>aCtVutJrWVKoX4&?auP^2JU zgU3zhJCz3aR>ee)h%*!{4~(@Iyd1K3lc*nKBtK%wVxz&mRiU19k&#m#%yS|H%I@9P zOR2Jf2e>B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yUD|{tZuHP(0L_R1zk~a=@H+{g-igFwa{zUrrz$%@kP=gal zCtn=|(@Apt4bN%uds3@(GKmM-sIR7zOi*wGJTkD#z=e%Yvxvm$Z#pUG$RI8lSY@0( znijGmR}Ti+q)f<4#BWrFoUl3zer)`P#-)#Lf(z}02Qj2o#@(FxG~MVpEwZ2RVs*CQ z^^|x1Upp-|T-3?#Y$ae%iJCE z<-f-|AwEBQs(*N}*wwgt&}Q?s&o=mk9CF(hdmCvF=2I6b2Tw#&t0e8O^zh1GObgsr j;xS$!SFT*S&V>E|u%JZ=RB3_C00000NkvXXu0mjf@HTcY literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_check_white.png b/app/src/main/res/drawable-xhdpi/ic_check_white.png new file mode 100644 index 0000000000000000000000000000000000000000..0eb7fb32e5240e188241afa778abe897ea19c9f2 GIT binary patch literal 2046 zcmVC3Oh>tKMY^=aC!5;?sD9Ij(W+_VLq?rcg zA0MD%+MgQKQ6$C@n;#<8D7yPr=R0ttx(+_U#u zd+l$pwa=bJ!otGB!otGB!otGB!otGB!otF$@Sv3H1{Q&Xz_H*P;4*MGco1v?&w^LL zHt;6d#?Q|3I|smB;8JitI0k%#_wHtU`tDBe0rmukfWyJ@;7o7BWF98>WTa-DFu=FNaY~;K^JujXAF!%)c8Hczj*bA-)tHFniTR*V#MOD1a zcz;Ei2YKfGoEOTB83`$#FP;At_zPpKX^>|=!_Zmdjsz17P{OctkezQj&Tu41I4U;5 z0B?bxatJ45V1OjsB6Gqb6AbVrJtl7018&rPku^ufAJ2nN={D&~df`>@eM37{R^wN> zDn9G;UCCX&#JR3W2LtqCZs&XOZ$k|roqm|>m6blt?xq{?w+fs{BcvM%ZLGXWx%7cZ(%38`4q`FoW<)9FuE34? z;`u$&w6BUIp)Sp}x9MwG*v_1EOUH4Ima@V35>2azI-rSpHJyv!A!h!Mgxz%nkrbccBU=b5BtN_!^K z^P4;QJDb2IVH!a8Y97+u^N$21HM4Zk~^MjC@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ic_check_white.png b/app/src/main/res/drawable-xxhdpi/ic_check_white.png new file mode 100644 index 0000000000000000000000000000000000000000..46b36b527baf390b6b33fe570c600eb22b1e4015 GIT binary patch literal 2955 zcmaJ@cQ_mB7mgL9sI5X(jZ(F0uUd^QW=c@4Aokv?N@>wXqehHc*G!F2+}0Mf(TF{3 zUZcdSQB_-i>AnB|p645Xe9w2zdEax+^PXgLQ+*}|5CZ@JU@|lSTaxe8KbsCnK1q7Z zO#r|ZOGB_WG<@cJz7G;Q!PDzD?eJ}0*U|RTORtw~Z@?h>6rJa6Ixhb+mOXKM$1pQ?s_<0Y2!oqz?`C!df^m=X*IW1v^7$}8wSxv|qz zryLf#w$L23`@8VGLuO7bZ1-d+BB~(BR9x4Bc(@%>i5+H@RZYN5v(nCCn&w;X$hhjfsA5C8?5HI0h;iE?W>9C3CHwR&bpydSC5Z; zR27mre5O@HvjHg&TRFWO)d6d;4!@krg7{m-aqdORxn+a0{7sbJ_1nPfXlaRjw3I*F z3zoA1+f`c+LWhUSN= z&L@0rE)k3-)LHMTdlZao5JiXt1Vgr8GmU(_l7zl?ITDz*dnx_Z<3z5Br@!GL&5M=Y zD!3u7{p@(j(|ullbA{WP#r*!bdYXRRKT2sL5ULR^R@s#Pr8z)B{W*<~Z*C_;5B&7P#Pb^R_tb-*Xg~HF_2SR!XPdKT4Xeo0L$w3xLGH4daf&qp{^i z;X}eUQP3M65({Pu`8s67BFt*zfDPqKx-NoJR|UOdYJYJjvrBw*I*iGs#3R*q~MR# zAXGVHl0TG~LDRn+^XS#ljZw{3 z^H5U@F=l5Ln`NK9M3c{z zr*dKbA#o_~AG@>r6V#6k$@CHASyTf?1JEJ%v|aR(YrM@g6!m)Ecim-Fwz~KH#+FlZ;q=u#qL;bTw_5`Fs@ymg(-uPipS5b?pD8#u*%Fr z{F_PE;OraJ@me*gymvZkBX*M6+%qu4wE$jm!h(8zd*28(?>e;(yC1yt5HeteJKG+T z(Fn_3tXuUt?7{v?>Q|7#vcps?^UC+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Cf(9E$s$uAo)(TIZel|1HyXnFgcClAUnS3HF_V8oLH$l^RTulvV+OF8`F z1!Ixbzk+WCvD$A4MS@$L-MM%oj8yU3oKv|*w8P}iq^7L%?Y&A6jl{di@oG~4SngC@ zwcQ_i{Dh_jnbkXn93EULXA2$0n9CWW^Q(V04Z38R`r*HosL>W%enZc<`L)%M%HJA2 z*48FBx?xgbGvre(^#QbSNoClnjc>_>CuOvx;J%`2IF|&l-j{ftSEK(kt?lSiu2Eo( zXl%$L4H52N-mfs=rgf@}iVY}wEdq<7A~1Xf`b&RxX}c&wRLD;+*RbbLN+Fl$-b1k` zM9kpv^s7aUAqsGrV*-xFS1jB{Agzg4x6XW>L9SF%v1UXHBdXE#It zTD7k0cL}S03~#<#t+>#9_ Date: Fri, 20 Feb 2015 11:23:48 +0000 Subject: [PATCH 3/5] Add Flashcard activity to dev activity ,update flashcard layout --- .../kanshu/kanshu/DevelopmentActivity.java | 3 + .../kanshu/ExerciseOptionsListFragment.java | 5 +- .../widget/FlashCardExerciseAdapter.java | 82 ------------------- .../main/res/layout/activity_development.xml | 5 ++ .../layout/row_falshcard_exercise_options.xml | 16 +++- app/src/main/res/values/colors.xml | 1 + 6 files changed, 26 insertions(+), 86 deletions(-) delete mode 100644 app/src/main/java/com/kanshu/kanshu/widget/FlashCardExerciseAdapter.java diff --git a/app/src/main/java/com/kanshu/kanshu/DevelopmentActivity.java b/app/src/main/java/com/kanshu/kanshu/DevelopmentActivity.java index f1a8eed..7d365f4 100644 --- a/app/src/main/java/com/kanshu/kanshu/DevelopmentActivity.java +++ b/app/src/main/java/com/kanshu/kanshu/DevelopmentActivity.java @@ -50,4 +50,7 @@ public void onFeedbackActivity(View view) { public void onSettingsActivity(View view) { startActivity(new Intent(this, SettingsActivity.class)); } + public void onFlashCardActivity(View view) { + startActivity(new Intent(this, FlashCardExerciseActivity.class)); + } } \ No newline at end of file diff --git a/app/src/main/java/com/kanshu/kanshu/ExerciseOptionsListFragment.java b/app/src/main/java/com/kanshu/kanshu/ExerciseOptionsListFragment.java index c68c693..0d5f347 100644 --- a/app/src/main/java/com/kanshu/kanshu/ExerciseOptionsListFragment.java +++ b/app/src/main/java/com/kanshu/kanshu/ExerciseOptionsListFragment.java @@ -73,16 +73,19 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, mRecyclerView.setAdapter(mAdapter); ((FlashCardExerciseAdapter)mAdapter).SetOnItemClickListener(new OnItemClickListener() { - + View vHelper; @Override public void onItemClick(View v , int position) { + vHelper = v; System.out.println("clicked pos :>" + position); FlashCardExerciseAdapter.ViewHolder holder = (FlashCardExerciseAdapter.ViewHolder )(v.getTag()); if (mFlashcardExerciseOptions.get(position).isCorrect_answer()){ //holder.correctOptionIV.setVisibility(View.VISIBLE); //holder.wrongOptionIV.setVisibility(View.GONE); + vHelper.setBackgroundColor(getResources().getColor(R.color.white)); v.setBackgroundColor(getResources().getColor(R.color.correct_answer_green)); }else{ + vHelper.setBackgroundColor(getResources().getColor(R.color.white)); v.setBackgroundColor(getResources().getColor(R.color.primary_light_red)); //holder.wrongOptionIV.setVisibility(View.VISIBLE); //holder.correctOptionIV.setVisibility(View.GONE); diff --git a/app/src/main/java/com/kanshu/kanshu/widget/FlashCardExerciseAdapter.java b/app/src/main/java/com/kanshu/kanshu/widget/FlashCardExerciseAdapter.java deleted file mode 100644 index 7b4c773..0000000 --- a/app/src/main/java/com/kanshu/kanshu/widget/FlashCardExerciseAdapter.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.kanshu.kanshu.widget; - -import android.support.v7.widget.RecyclerView; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; - -import com.kanshu.kanshu.R; -import com.kanshu.kanshu.model.FlashcardExerciseOption; - -import java.util.List; - - -/** - * Created by alouanemed on 17-02-2015. - */ -public class FlashCardExerciseAdapter extends RecyclerView.Adapter { - - private List flashcardExerciseOptionsList; - - // Provide a reference to the views for each data item - // Complex data items may need more than one view per item, and - // you provide access to all the views for a data item in a view holder - public class FlashCardExerciseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ - public TextView optionNbTV; - public TextView optionTitleTV; - public ImageView deleteBtn; - - public FlashCardExerciseViewHolder(View v) { - super(v); - optionNbTV = (TextView) v.findViewById(R.id.option_nb); - optionTitleTV = (TextView) v.findViewById(R.id.option_title); - deleteBtn = (ImageView) v.findViewById(R.id.option_delete); - } - - @Override - public void onClick(View view) { - Log.d("FlashCardExerciseAdapter", "onClick " + getPosition() ); - } - } - - - public FlashCardExerciseAdapter(List lst) { - flashcardExerciseOptionsList = lst; - } - - // Create new views (invoked by the layout manager) - @Override - public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_falshcard_exercise_options, parent, false); - - RecyclerView.ViewHolder vh = new FlashCardExerciseViewHolder(v); - return vh; - } - - @Override - public int getItemViewType(int position) { - //@todo replace this with a real get item new type method based on the real data - //right now I would just make every 5th card an indicator - if (position % 5 == 0) { - return 1; - } else { - return 0; - } - } - - // Replace the contents of a view (invoked by the layout manager) - @Override - public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { - FlashcardExerciseOption _Flashcard_ExerciseOption = flashcardExerciseOptionsList.get(position); - //@todo set the real data here. - - } - - @Override - public int getItemCount() { - return flashcardExerciseOptionsList.size(); - } -} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_development.xml b/app/src/main/res/layout/activity_development.xml index 02621bc..5dc572b 100644 --- a/app/src/main/res/layout/activity_development.xml +++ b/app/src/main/res/layout/activity_development.xml @@ -66,6 +66,11 @@ android:layout_height="wrap_content" android:text="Settings" android:onClick="onSettingsActivity"/> +