Skip to content
This repository has been archived by the owner on Apr 30, 2020. It is now read-only.

Commit

Permalink
joined two project, updated to version 0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio Biola authored and Fabio Biola committed Dec 30, 2014
1 parent 1f45f9c commit 361e8f2
Show file tree
Hide file tree
Showing 75 changed files with 402 additions and 818 deletions.
6 changes: 3 additions & 3 deletions MaterialTabTest/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"

defaultConfig {
applicationId "it.neokree.materialtabtest"
minSdkVersion 14
minSdkVersion 10
targetSdkVersion 21
versionCode 1
versionName "1.0"
Expand All @@ -16,10 +15,11 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.0'
compile project(':MaterialTabsModule')
//compile 'it.neokree:MaterialTabs:T'
Expand Down
8 changes: 6 additions & 2 deletions MaterialTabTest/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.neokree.materialtabtest" >
package="it.neokree.materialtabtest">

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="it.neokree.materialtabtest.MainActivity"
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".IconTabActivity" />
<activity android:name=".SwipableIconTabActivity" />
<activity android:name=".SwipableTextTabActivity" />
<activity android:name=".TextTabActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package it.neokree.materialtabtest;

import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

/**
Expand All @@ -17,7 +16,8 @@ public class FragmentText extends Fragment{
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
TextView text = new TextView(container.getContext());
text.setText("Section");
text.setText("Fragment content");
text.setGravity(Gravity.CENTER);

return text;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,42 @@
package it.neokree.materialtabstestwithicons;
package it.neokree.materialtabtest;


import android.app.Activity;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
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.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import it.neokree.materialtabs.MaterialTab;
import it.neokree.materialtabs.MaterialTabHost;
import it.neokree.materialtabs.MaterialTabListener;


public class MainActivity extends ActionBarActivity implements MaterialTabListener {

/**
* Created by neokree on 30/12/14.
*/
public class IconTabActivity extends ActionBarActivity implements MaterialTabListener {
private ViewPager pager;
private ViewPagerAdapter pagerAdapter;
MaterialTabHost tabHost;

private Resources res;

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

setContentView(R.layout.activity_icons);
res = this.getResources();

// init toolbar (old action bar)

Toolbar toolbar = (Toolbar) this.findViewById(R.id.toolbar);
toolbar.setTitleTextColor(Color.WHITE);
this.setSupportActionBar(toolbar);

tabHost = (MaterialTabHost) this.findViewById(R.id.materialTabHost);
pager = (ViewPager) this.findViewById(R.id.viewpager);

tabHost = (MaterialTabHost) this.findViewById(R.id.tabHost);
pager = (ViewPager) this.findViewById(R.id.pager);
// init view pager
pagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
pager.setAdapter(pagerAdapter);
Expand All @@ -56,7 +47,6 @@ public void onPageSelected(int position) {
tabHost.setSelectedNavigationItem(position);
}
});

// insert all tabs from pagerAdapter data
for (int i = 0; i < pagerAdapter.getCount(); i++) {
tabHost.addTab(
Expand All @@ -65,15 +55,11 @@ public void onPageSelected(int position) {
.setTabListener(this)
);
}

//tabHost.setAccentColor(Color.BLUE);
}

@Override
public void onTabSelected(MaterialTab tab) {
// when the tab is clicked the pager swipe content to the tab position
// when the tab is clicked the pager swipe content to the tab position
pager.setCurrentItem(tab.getPosition());

}

@Override
Expand All @@ -84,21 +70,17 @@ public void onTabReselected(MaterialTab tab) {
public void onTabUnselected(MaterialTab tab) {
}

private class ViewPagerAdapter extends FragmentStatePagerAdapter {

private class ViewPagerAdapter extends FragmentStatePagerAdapter {
public ViewPagerAdapter(FragmentManager fm) {
super(fm);
}

public Fragment getItem(int num) {
return new IndexFragment();
return new FragmentText();
}

@Override
public int getCount() {
return 3;
}

@Override
public CharSequence getPageTitle(int position) {
switch(position) {
Expand All @@ -108,12 +90,10 @@ public CharSequence getPageTitle(int position) {
default: return null;
}
}

}

}
/*
* It doesn't matter the color of the icons, but they must have solid colors
*/
* It doesn't matter the color of the icons, but they must have solid colors
*/
private Drawable getIcon(int position) {
switch(position) {
case 0:
Expand All @@ -122,20 +102,8 @@ private Drawable getIcon(int position) {
return res.getDrawable(R.drawable.ic_group_black_24dp);
case 2:
return res.getDrawable(R.drawable.ic_notifications_off_white_24dp);

}
return null;
}

public class IndexFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
TextView text = new TextView(container.getContext());
text.setText("Section");
text.setGravity(Gravity.CENTER);
return text;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package it.neokree.materialtabtest;

/**
* Created by neokree on 30/12/14.
*/

import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
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.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;

import it.neokree.materialtabs.MaterialTab;
import it.neokree.materialtabs.MaterialTabHost;
import it.neokree.materialtabs.MaterialTabListener;

/**
* Created by neokree on 30/12/14.
*/
public class SwipableIconTabActivity extends ActionBarActivity implements MaterialTabListener {
private ViewPager pager;
private ViewPagerAdapter pagerAdapter;
MaterialTabHost tabHost;
private Resources res;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_icons);
res = this.getResources();
// init toolbar (old action bar)

Toolbar toolbar = (Toolbar) this.findViewById(R.id.toolbar);
toolbar.setTitleTextColor(Color.WHITE);
this.setSupportActionBar(toolbar);

tabHost = (MaterialTabHost) this.findViewById(R.id.tabHost);
pager = (ViewPager) this.findViewById(R.id.pager);
// init view pager
pagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
pager.setAdapter(pagerAdapter);
pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
// when user do a swipe the selected tab change
tabHost.setSelectedNavigationItem(position);
}
});
// insert all tabs from pagerAdapter data
for (int i = 0; i < pagerAdapter.getCount(); i++) {
tabHost.addTab(
tabHost.newTab()
.setIcon(getIcon(i))
.setTabListener(this)
);
}
}
@Override
public void onTabSelected(MaterialTab tab) {
// when the tab is clicked the pager swipe content to the tab position
pager.setCurrentItem(tab.getPosition());
}

@Override
public void onTabReselected(MaterialTab tab) {
}

@Override
public void onTabUnselected(MaterialTab tab) {
}

private class ViewPagerAdapter extends FragmentStatePagerAdapter {
public ViewPagerAdapter(FragmentManager fm) {
super(fm);
}
public Fragment getItem(int num) {
return new FragmentText();
}
@Override
public int getCount() {
return 6;
}
@Override
public CharSequence getPageTitle(int position) {
return "tab";
}
}
/*
* It doesn't matter the color of the icons, but they must have solid colors
*/
private Drawable getIcon(int position) {
return res.getDrawable(R.drawable.ic_person_black_24dp);
}

}
Loading

0 comments on commit 361e8f2

Please sign in to comment.