-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
practicing view pager with imageview
- Loading branch information
Showing
18 changed files
with
447 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
app/src/main/java/com/apaza/moises/practicegreendao/login/SignUpActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.apaza.moises.practicegreendao.login; | ||
|
||
import android.os.Bundle; | ||
import android.support.design.widget.FloatingActionButton; | ||
import android.support.design.widget.Snackbar; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v4.app.FragmentManager; | ||
import android.support.v4.app.FragmentTransaction; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.View; | ||
|
||
import com.apaza.moises.practicegreendao.R; | ||
|
||
public class SignUpActivity extends AppCompatActivity implements SignUpFragment.OnFragmentSignUpListener{ | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_signup); | ||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
|
||
toolbar.setVisibility(View.GONE); | ||
showFragment(SignUpFragment.newInstance()); | ||
|
||
/*FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); | ||
fab.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) | ||
.setAction("Action", null).show(); | ||
} | ||
});*/ | ||
|
||
} | ||
|
||
public void showFragment(Fragment fragment){ | ||
FragmentManager fm = getSupportFragmentManager(); | ||
FragmentTransaction ft = fm.beginTransaction(); | ||
ft.addToBackStack(fragment.getClass().getSimpleName()); | ||
ft.replace(R.id.containerSignUp, fragment); | ||
ft.commit(); | ||
} | ||
|
||
@Override | ||
public void onSignUpClick() { | ||
|
||
} | ||
} |
134 changes: 134 additions & 0 deletions
134
app/src/main/java/com/apaza/moises/practicegreendao/login/SignUpFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
package com.apaza.moises.practicegreendao.login; | ||
|
||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v4.view.PagerAdapter; | ||
import android.support.v4.view.ViewPager; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.Button; | ||
import android.widget.FrameLayout; | ||
import android.widget.ImageView; | ||
|
||
import com.apaza.moises.practicegreendao.R; | ||
import com.bumptech.glide.Glide; | ||
|
||
import me.relex.circleindicator.CircleIndicator; | ||
|
||
public class SignUpFragment extends Fragment { | ||
|
||
private static final String ARG_PARAM1 = "param1"; | ||
private String mParam1; | ||
|
||
private View view; | ||
private ViewPager viewPager; | ||
private Button btnSignUp; | ||
|
||
private ImagePageAdapter imagePageAdapter; | ||
private CircleIndicator circleIndicator; | ||
|
||
public int[] mResources = {R.drawable.vegeta, R.drawable.goku, R.drawable.buu}; | ||
|
||
private OnFragmentSignUpListener mListener; | ||
|
||
public static SignUpFragment newInstance() { | ||
SignUpFragment fragment = new SignUpFragment(); | ||
return fragment; | ||
} | ||
|
||
public SignUpFragment() { | ||
// Required empty public constructor | ||
} | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | ||
view = inflater.inflate(R.layout.fragment_sign_up, container, false); | ||
setup(); | ||
return view; | ||
} | ||
|
||
private void setup(){ | ||
viewPager = (ViewPager)view.findViewById(R.id.viewPagerSignUp); | ||
imagePageAdapter = new ImagePageAdapter(getActivity().getApplicationContext()); | ||
viewPager.setAdapter(imagePageAdapter); | ||
|
||
circleIndicator = (CircleIndicator)view.findViewById(R.id.indicator); | ||
circleIndicator.setViewPager(viewPager); | ||
btnSignUp = (Button) view.findViewById(R.id.signup); | ||
btnSignUp.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
mListener.onSignUpClick(); | ||
} | ||
}); | ||
} | ||
|
||
public void onButtonPressed(Uri uri) { | ||
if (mListener != null) { | ||
mListener.onSignUpClick(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAttach(Activity activity) { | ||
super.onAttach(activity); | ||
try { | ||
mListener = (OnFragmentSignUpListener) activity; | ||
} catch (ClassCastException e) { | ||
throw new ClassCastException(activity.toString() + " must implement OnFragmentSignUpListener"); | ||
} | ||
} | ||
|
||
@Override | ||
public void onDetach() { | ||
super.onDetach(); | ||
mListener = null; | ||
} | ||
|
||
public interface OnFragmentSignUpListener { | ||
void onSignUpClick(); | ||
} | ||
|
||
public class ImagePageAdapter extends PagerAdapter{ | ||
|
||
private Context context; | ||
public ImagePageAdapter(Context context){ | ||
this.context = context; | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return mResources.length; | ||
} | ||
|
||
@Override | ||
public boolean isViewFromObject(View view, Object object) { | ||
return (view == (FrameLayout)object); | ||
} | ||
|
||
@Override | ||
public Object instantiateItem(ViewGroup container, int position) { | ||
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); | ||
View view = inflater.inflate(R.layout.pager_layout, container, false); | ||
ImageView imageView = (ImageView)view.findViewById(R.id.imageView); | ||
//imageView.setImageResource(mResources[position]); | ||
Glide.with(getActivity()) | ||
.load(mResources[position]) | ||
.centerCrop() | ||
.into(imageView); | ||
|
||
container.addView(view); | ||
return view; | ||
} | ||
|
||
@Override | ||
public void destroyItem(ViewGroup container, int position, Object object) { | ||
container.removeView((FrameLayout)object); | ||
} | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
app/src/main/java/com/apaza/moises/practicegreendao/login/SplashActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.apaza.moises.practicegreendao.login; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.os.CountDownTimer; | ||
import android.support.design.widget.FloatingActionButton; | ||
import android.support.design.widget.Snackbar; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import com.apaza.moises.practicegreendao.MainActivity; | ||
import com.apaza.moises.practicegreendao.R; | ||
|
||
public class SplashActivity extends AppCompatActivity { | ||
|
||
private TextView counter; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_splash); | ||
/*Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar);*/ | ||
counter = (TextView)findViewById(R.id.counter); | ||
|
||
startSplash(); | ||
} | ||
|
||
private void startSplash(){ | ||
new CountDownTimer(7000, 1000) { | ||
public void onTick(long millisUntilFinished) { | ||
counter.setText("" + millisUntilFinished / 1000); | ||
} | ||
|
||
public void onFinish() { | ||
counter.setText("Go!"); | ||
//goToMainActivity(); | ||
goToSignUpActivity(); | ||
} | ||
}.start(); | ||
} | ||
|
||
private void goToMainActivity(){ | ||
Intent intent = new Intent(this, MainActivity.class); | ||
startActivity(intent); | ||
} | ||
|
||
private void goToSignUpActivity(){ | ||
Intent intent = new Intent(this, SignUpActivity.class); | ||
startActivity(intent); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.design.widget.CoordinatorLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" | ||
android:layout_height="match_parent" android:fitsSystemWindows="true" | ||
tools:context="com.apaza.moises.practicegreendao.login.SignUpActivity"> | ||
|
||
<android.support.design.widget.AppBarLayout android:layout_height="wrap_content" | ||
android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay"> | ||
|
||
<android.support.v7.widget.Toolbar android:id="@+id/toolbar" | ||
android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" | ||
android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /> | ||
|
||
</android.support.design.widget.AppBarLayout> | ||
|
||
<include layout="@layout/content_signup" /> | ||
|
||
<!--<android.support.design.widget.FloatingActionButton android:id="@+id/fab" | ||
android:layout_width="wrap_content" android:layout_height="wrap_content" | ||
android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" | ||
android:src="@android:drawable/ic_dialog_email" />--> | ||
|
||
</android.support.design.widget.CoordinatorLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.design.widget.CoordinatorLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:fitsSystemWindows="true" | ||
android:background="@color/colorPrimary" | ||
tools:context="com.apaza.moises.practicegreendao.login.SplashActivity"> | ||
|
||
<!--<android.support.design.widget.AppBarLayout android:layout_height="wrap_content" | ||
android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay"> | ||
<android.support.v7.widget.Toolbar android:id="@+id/toolbar" | ||
android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" | ||
android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /> | ||
</android.support.design.widget.AppBarLayout>--> | ||
|
||
<include layout="@layout/content_splash" /> | ||
|
||
</android.support.design.widget.CoordinatorLayout> |
Oops, something went wrong.