Skip to content

Commit

Permalink
修改包名。修改示例
Browse files Browse the repository at this point in the history
  • Loading branch information
chiemy committed Aug 31, 2014
1 parent 796f6e0 commit 46f3e3c
Show file tree
Hide file tree
Showing 19 changed files with 118 additions and 86 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.cviewpager"
package="com.chiemy.jellyviewpager"
android:versionCode="1"
android:versionName="1.0" >

Expand All @@ -14,7 +14,7 @@
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:name="com.chiemy.jellyviewpager.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Binary file added res/drawable-hdpi/a.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/b.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/c.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/d.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/e.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="match_parent"
android:background="#363636"
>

<com.example.cviewpager.JellyViewPager
<com.chiemy.jellyviewpager.widget.JellyViewPager
android:id="@+id/myViewPager1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/handle"
>

</com.example.cviewpager.JellyViewPager>
</com.chiemy.jellyviewpager.widget.JellyViewPager>

<LinearLayout
android:id="@+id/handle"
Expand Down
47 changes: 26 additions & 21 deletions res/layout/frag_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,34 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/card_bg"
>
<TextView
android:id="@+id/tv"
android:background="@drawable/card_bg" >

<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
android:layout_height="match_parent"
android:scaleType="centerCrop" />

<RatingBar
android:id="@+id/ratingBar1"
android:layout_width="wrap_content"
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:padding="10dp"
android:text="@string/text2"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/white"
android:background="#AA363636"
/>
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/ratingBar1"
android:layout_centerHorizontal="true"
android:text="Button" />
android:layout_alignParentBottom="true"
android:padding="10dp"
android:text="@string/text1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/white"
android:background="#AA363636"
/>

</RelativeLayout>
</RelativeLayout>
4 changes: 3 additions & 1 deletion res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">CViewPager</string>
<string name="app_name">JellyViewPager</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="text1">便便的离去,是马桶的吸引,还是屁股的不挽留?</string>
<string name="text2">美丽风景……</string>

</resources>
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.example.cviewpager;
package com.chiemy.jellyviewpager;


import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.View;
import android.widget.Toast;

import com.chiemy.jellyviewpager.R;
import com.chiemy.jellyviewpager.widget.JellyViewPager;

public class MainActivity extends FragmentActivity {
JellyViewPager pager;
Expand All @@ -21,17 +25,13 @@ protected void onCreate(Bundle savedInstanceState) {
public void onPageScrollStateChanged(int state) {
switch(state){
case 1: //正在滑动
System.out.println(">>>正在滑动");
break;
case 2: //滑动结束
System.out.println(">>>滑动结束");
break;
}
}

@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
System.out.println(">>>onPageScrolled");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.example.cviewpager;
package com.chiemy.jellyviewpager;

import com.chiemy.jellyviewpager.util.Constant;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
Expand All @@ -13,7 +16,11 @@ public TestFragPagerAdapter(FragmentManager fm) {

@Override
public Fragment getItem(int arg0) {
return new TestFragment();
Bundle bundle = new Bundle();
bundle.putInt(Constant.KEY, Constant.images[arg0%getCount()]);
Fragment frag = new TestFragment();
frag.setArguments(bundle);
return frag;
}

@Override
Expand Down
46 changes: 46 additions & 0 deletions src/com/chiemy/jellyviewpager/TestFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.chiemy.jellyviewpager;

import com.chiemy.jellyviewpager.util.Constant;

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

public class TestFragment extends Fragment {
boolean visible = true;
@Override
public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.frag_layout, container, false);
initUI(rootView);
return rootView;
}

private void initUI(View root){
final View tv1 = root.findViewById(R.id.textView1);
final View tv2 = root.findViewById(R.id.textView2);
ImageView iv = (ImageView) root.findViewById(R.id.imageView1);
Bundle bundle = getArguments();
int res = bundle.getInt(Constant.KEY, R.drawable.a);
iv.setImageResource(res);
iv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(!visible){
visible = true;
tv1.setVisibility(View.VISIBLE);
tv2.setVisibility(View.VISIBLE);
}else{
visible = false;
tv1.setVisibility(View.INVISIBLE);
tv2.setVisibility(View.INVISIBLE);
}
}
});
}

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package com.example.cviewpager;
package com.chiemy.jellyviewpager;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.chiemy.jellyviewpager.R;

public class TestPagerAdapter extends PagerAdapter{

private LayoutInflater inflater;

public TestPagerAdapter(Context context){
inflater = LayoutInflater.from(context);
}
Expand All @@ -26,8 +29,6 @@ public boolean isViewFromObject(View arg0, Object arg1) {
@Override
public Object instantiateItem(ViewGroup container, int position) {
View view = inflater.inflate(R.layout.frag_layout, null);
TextView tv = (TextView) view.findViewById(R.id.tv);
tv.setText(position+"");
container.addView(view);
return view;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
*/

package com.example.cviewpager;
package com.chiemy.jellyviewpager.util;

import android.annotation.TargetApi;
import android.os.Build;
Expand Down
12 changes: 12 additions & 0 deletions src/com/chiemy/jellyviewpager/util/Constant.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.chiemy.jellyviewpager.util;

import com.chiemy.jellyviewpager.R;
import com.chiemy.jellyviewpager.R.drawable;

public class Constant {
public static final String KEY = "image";

public static int [] images = {R.drawable.a,R.drawable.b,
R.drawable.c,R.drawable.d,R.drawable.e};

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.cviewpager;
package com.chiemy.jellyviewpager.util;

import com.facebook.rebound.BaseSpringSystem;
import com.facebook.rebound.SpringLooper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.cviewpager;
package com.chiemy.jellyviewpager.widget;

import android.annotation.TargetApi;
import android.content.Context;
Expand All @@ -17,6 +17,7 @@
import android.view.ViewGroup;
import android.widget.Toast;

import com.chiemy.jellyviewpager.util.SpringSystem;
import com.facebook.rebound.BaseSpringSystem;
import com.facebook.rebound.SimpleSpringListener;
import com.facebook.rebound.Spring;
Expand Down Expand Up @@ -155,7 +156,7 @@ private void prePage() {
*
* @return
*/
private boolean hasNext() {
public boolean hasNext() {
return getCurrentItem() < mAdapter.getCount() - 1;
}

Expand All @@ -164,7 +165,7 @@ private boolean hasNext() {
*
* @return
*/
private boolean hasPre() {
public boolean hasPre() {
return getCurrentItem() > 0;
}

Expand Down Expand Up @@ -251,8 +252,6 @@ private void animOutIfNeeded(float scrollDis, float velocityY) {
} else {
// 角度回正
rotateSpring.setEndValue(0);
Toast.makeText(getContext(), "已经是最后一条", Toast.LENGTH_SHORT)
.show();
}
} else if (velocityY < -FLING_VELOCITY
|| (scrollDis < -OUT_DISTANCE_BOUDARY)) { // 上移
Expand All @@ -261,8 +260,6 @@ private void animOutIfNeeded(float scrollDis, float velocityY) {
rotateSpring.setAtRest();
} else {
rotateSpring.setEndValue(0);
Toast.makeText(getContext(), "已经是第一条", Toast.LENGTH_SHORT)
.show();
}
} else {
// 不移动
Expand Down
19 changes: 0 additions & 19 deletions src/com/example/cviewpager/TestFragment.java

This file was deleted.

21 changes: 0 additions & 21 deletions src/com/example/cviewpager/ViewHolder.java

This file was deleted.

0 comments on commit 46f3e3c

Please sign in to comment.