Skip to content

Commit

Permalink
Added Fragments #12
Browse files Browse the repository at this point in the history
  • Loading branch information
harshendrashah committed Dec 18, 2017
1 parent b5f269d commit 954478a
Show file tree
Hide file tree
Showing 31 changed files with 1,339 additions and 583 deletions.
1 change: 1 addition & 0 deletions LangTutor/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
Expand Down
71 changes: 0 additions & 71 deletions LangTutor/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,77 +38,6 @@
android:label="@string/french"
android:parentActivityName=".MainActivity"/>

<!-- Hindi language Categories-->
<activity
android:name=".HIndi.HindiAlphabetsActivity"
android:label="@string/alphabets"
android:parentActivityName=".HIndi.HindiActivity"/>
<activity
android:name=".HIndi.HindiNumbersActivity"
android:label="@string/numbers"
android:parentActivityName=".HIndi.HindiActivity"/>
<activity
android:name=".HIndi.HindiColorsActivity"
android:label="@string/colors"
android:parentActivityName=".HIndi.HindiActivity"/>
<activity
android:name=".HIndi.HindiPhrasesActivity"
android:label="@string/phrases"
android:parentActivityName=".HIndi.HindiActivity"/>

<!-- Gujarati language Categories-->
<activity
android:name=".Gujarati.GujaratiAlphabetsActivity"
android:label="@string/alphabets"
android:parentActivityName=".Gujarati.GujaratiActivity"/>
<activity
android:name=".Gujarati.GujaratiNumbersActivity"
android:label="@string/numbers"
android:parentActivityName=".Gujarati.GujaratiActivity"/>
<activity
android:name=".Gujarati.GujaratiColorsActivity"
android:label="@string/colors"
android:parentActivityName=".Gujarati.GujaratiActivity"/>
<activity
android:name=".Gujarati.GujaratiPhrasesActivity"
android:label="@string/phrases"
android:parentActivityName=".Gujarati.GujaratiActivity"/>

<!-- Marathi language Categories-->
<activity
android:name=".Marathi.MarathiAlphabetsActivity"
android:label="@string/alphabets"
android:parentActivityName=".Marathi.MarathiActivity"/>
<activity
android:name=".Marathi.MarathiNumbersActivity"
android:label="@string/numbers"
android:parentActivityName=".Marathi.MarathiActivity"/>
<activity
android:name=".Marathi.MarathiColorsActivity"
android:label="@string/colors"
android:parentActivityName=".Marathi.MarathiActivity"/>
<activity
android:name=".Marathi.MarathiPhrasesActivity"
android:label="@string/phrases"
android:parentActivityName=".Marathi.MarathiActivity"/>

<!-- French language Categories-->
<activity
android:name=".French.FrenchAlphabetsActivity"
android:label="@string/alphabets"
android:parentActivityName=".French.FrenchActivity"/>
<activity
android:name=".French.FrenchNumbersActivity"
android:label="@string/numbers"
android:parentActivityName=".French.FrenchActivity"/>
<activity
android:name=".French.FrenchColorsActivity"
android:label="@string/colors"
android:parentActivityName=".French.FrenchActivity"/>
<activity
android:name=".French.FrenchPhrasesActivity"
android:label="@string/phrases"
android:parentActivityName=".French.FrenchActivity"/>

</application>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
package com.shah.langtutor.French;

import android.content.Intent;
import android.support.v4.app.NavUtils;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

import com.shah.langtutor.Gujarati.GujaratiActivity;
import com.shah.langtutor.Gujarati.GujaratiAlphabetsActivity;
import com.shah.langtutor.Gujarati.GujaratiColorsActivity;
import com.shah.langtutor.Gujarati.GujaratiNumbersActivity;
import com.shah.langtutor.Gujarati.GujaratiPhrasesActivity;
import com.shah.langtutor.Marathi.MarathiCategoryAdapter;
import com.shah.langtutor.R;

public class FrenchActivity extends AppCompatActivity {
Expand All @@ -22,68 +17,14 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_french);

//Find View that shows Alphabets Category
TextView frenchAlphabets = (TextView) findViewById(R.id.french_alphabets);
// Find the view pager that will allow the user to swipe between fragments
ViewPager viewPager = (ViewPager) findViewById(R.id.french_viewpager);

//Set a ClickListener on that View
frenchAlphabets.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View view) {
//Creates new Intent to open {@link GujaratiAlphabetsActivity}
Intent fAlphabets = new Intent(FrenchActivity.this, GujaratiAlphabetsActivity.class);

//Start the new Activity;
startActivity(fAlphabets);
}
});
//Find View that shows Numbers Category
TextView frenchNumbers = (TextView) findViewById(R.id.french_numbers);

//Set a ClickListener on that View
frenchNumbers.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//Creates new Intent to open {@link GujaratiNumbersActivity}
Intent fNumbers = new Intent(FrenchActivity.this, GujaratiNumbersActivity.class);

//Start the new Activity;
startActivity(fNumbers);
}
});

//Find View that shows Colors Category
TextView frenchColors = (TextView) findViewById(R.id.french_colors);

//Set a ClickListener on that View
frenchColors.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View view) {
//Creates new Intent to open {@link GujaratiColorsActivity}
Intent fColors = new Intent(FrenchActivity.this, GujaratiColorsActivity.class);

//Start the new Activity;
startActivity(fColors);
}
});

//Find View that shows Phrases Category
TextView frenchPhrases = (TextView) findViewById(R.id.french_phrases);

//Set a ClickListener on that View
frenchPhrases.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View view) {
//Creates new Intent to open {@link GujaratiPhrasesActivity}
Intent fPhrases = new Intent(FrenchActivity.this, GujaratiPhrasesActivity.class);

//Start the new Activity;
startActivity(fPhrases);
}
});
// Create an adapter that knows which fragment should be shown on each page
FrenchCategoryAdapter adapter = new FrenchCategoryAdapter(getSupportFragmentManager());

// Set the adapter onto the view pager
viewPager.setAdapter(adapter);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.shah.langtutor.French;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.shah.langtutor.R;

/**
* A simple {@link Fragment} subclass.
*/
public class FrenchAlphabetsFragment extends Fragment {


public FrenchAlphabetsFragment() {
// Required empty public constructor
}


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.words_list, container,false);
return rootView;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.shah.langtutor.French;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;


/**
* Created by lenovo on 18-12-2017.
*/

public class FrenchCategoryAdapter extends FragmentPagerAdapter {

/**
* Create a new {@link FrenchCategoryAdapter} object.
*
* @param fm is the fragment manager that will keep each fragment's state in the adapter
* across swipes.
*/
public FrenchCategoryAdapter(FragmentManager fm) {
super(fm);
}

/**
* Return the {@link Fragment} that should be displayed for the given page number.
*/
@Override
public Fragment getItem(int position) {
if (position == 0) {
return new FrenchAlphabetsFragment();
} else if (position == 1) {
return new FrenchNumbersFragment();
} else if (position == 2) {
return new FrenchColorsFragment();
} else {
return new FrenchPhrasesFragment();
}
}

/**
* Return the total number of pages.
*/
@Override
public int getCount() {
return 4;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.shah.langtutor.French;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.shah.langtutor.R;

/**
* A simple {@link Fragment} subclass.
*/
public class FrenchColorsFragment extends Fragment {


public FrenchColorsFragment() {
// Required empty public constructor
}


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.words_list, container,false);
return rootView;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.shah.langtutor.French;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.shah.langtutor.R;

/**
* A simple {@link Fragment} subclass.
*/
public class FrenchNumbersFragment extends Fragment {


public FrenchNumbersFragment() {
// Required empty public constructor
}


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.words_list, container,false);
return rootView;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.shah.langtutor.French;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.shah.langtutor.R;

/**
* A simple {@link Fragment} subclass.
*/
public class FrenchPhrasesFragment extends Fragment {


public FrenchPhrasesFragment() {
// Required empty public constructor
}


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.phrases_list, container,false);
return rootView;
}

}
Loading

0 comments on commit 954478a

Please sign in to comment.