DevStore首页 > DEV资源 > 源码下载 > 源码详情

Android应用源码仿暴风影音安卓客户端源码

 
Jbul | 2014-09-02 20:38    浏览量(9378)    评论(26)    收藏(18)
功能分类:影音 支持平台:Android 运行环境:Android
开发语言:Java 开发工具:Eclipse 源码大小:3.87MB
下载源码 2733 人下载

源码简介

本项目是一个模仿暴风影音的UI项目源码,仿照的界面有菜单页,主页,分类页等,项目内的所有数据都使用的本地模拟数据,仿照度一般在大分辨设备上布局显示会有问题,480x800的分辨率应该正合适,默认编译版本4.2.2编码GBK,注释不多,需要的朋友可以下载看一下。

源码截图

  • 运行截图推荐界面
  • 导航板块
  • 搜索框
  • 电视剧显示
DevStore所有源码来自用户上传分享,版权问题及牵扯到商业纠纷均与DevStore无关。

源码片段

public class MainActivity extends TabActivity {
	private SlideMenu slideMenu;
	private TabHost tabHost;
	private LayoutInflater inflater;
	private Intent intent1, intent2, intent3, intent4, intent5, intent6;

	private long exitTime = 0;
	
	private static final int SWIPE_MIN_DISTANCE = 120;  
    private static final int SWIPE_MAX_OFF_PATH = 250;  
    private static final int SWIPE_THRESHOLD_VELOCITY = 200;  
    private GestureDetector gestureDetector;  
    View.OnTouchListener gestureListener;  
  
    int currentView = 0;  
    private static int maxTabIndex = 5;  

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK
				&& event.getAction() == KeyEvent.ACTION_DOWN) {
			if ((System.currentTimeMillis() - exitTime) > 2000) {
				Toast.makeText(MainActivity.this, "再按一次退出程序",
						Toast.LENGTH_SHORT).show();
				exitTime = System.currentTimeMillis();
			} else {
				finish();
				System.exit(0);
			}
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		
		
		gestureDetector = new GestureDetector(new MyGestureDetector());  
        gestureListener = new View.OnTouchListener() {  
            public boolean onTouch(View v, MotionEvent event) {  
                if (gestureDetector.onTouchEvent(event)) {  
                    return true;  
                }  
                return false;  
            }  
        };  
		
		// 抽屉效果
		slideMenu = (SlideMenu) findViewById(R.id.slide_menu);
		ImageView menuImg = (ImageView) findViewById(R.id.slide_firstmenu);
		menuImg.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (slideMenu.isMainScreenShowing()) {
					slideMenu.openMenu();
				} else {
					slideMenu.closeMenu();
				}
			}
		});

		intent1 = new Intent(MainActivity.this, FirstActivity.class);
		intent2 = new Intent(MainActivity.this, SecondActivity.class);
		intent3 = new Intent(MainActivity.this, SecondActivity.class);
		intent4 = new Intent(MainActivity.this, SecondActivity.class);
		intent5 = new Intent(MainActivity.this, SecondActivity.class);
		intent6 = new Intent(MainActivity.this, MoreInformationActivity.class);

		LayoutInflater inflater = LayoutInflater.from(MainActivity.this);
		View view1 = inflater.inflate(R.layout.tabitem_1, null);
		View view2 = inflater.inflate(R.layout.tabitem_2, null);
		View view3 = inflater.inflate(R.layout.tabitem_3, null);
		View view4 = inflater.inflate(R.layout.tabitem_4, null);
		View view5 = inflater.inflate(R.layout.tabitem_5, null);
		View view6 = inflater.inflate(R.layout.tabitem_6, null);

		// 创建TabHost
		// tabHost = (TabHost) findViewById(R.id.tabHost);
		// tabHost.setup();
		tabHost = getTabHost();
		TabSpec tabSpec1 = tabHost.newTabSpec("tab1").setIndicator(view1)
				.setContent(intent1);
		tabHost.addTab(tabSpec1);
		TabSpec tabSpec2 = tabHost.newTabSpec("tab2").setIndicator(view2)
				.setContent(intent2);
		tabHost.addTab(tabSpec2);
		TabSpec tabSpec3 = tabHost.newTabSpec("tab3").setIndicator(view3)
				.setContent(intent3);
		tabHost.addTab(tabSpec3);
		TabSpec tabSpec4 = tabHost.newTabSpec("tab4").setIndicator(view4)
				.setContent(intent4);
		tabHost.addTab(tabSpec4);
		TabSpec tabSpec5 = tabHost.newTabSpec("tab5").setIndicator(view5)
				.setContent(intent5);
		tabHost.addTab(tabSpec5);
		TabSpec tabSpec6 = tabHost.newTabSpec("tab6").setIndicator(view6)
				.setContent(intent6);
		tabHost.addTab(tabSpec6);

		Button imageButton1 = (Button) findViewById(R.id.imageButton1);
		imageButton1.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				// Toast.makeText(MainActivity.this, "123", Toast.LENGTH_SHORT)
				// .show();
				Intent newIntent = new Intent(MainActivity.this,
						LocalActivity.class);
				startActivity(newIntent);
			}
		});

		ImageView slide_menu_history = (ImageView) findViewById(R.id.slide_menu_history);
		slide_menu_history.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent newIntent = new Intent(MainActivity.this,
						HistoryActivity.class);
				startActivity(newIntent);
			}
		});

		ImageView slide_menu_search = (ImageView) findViewById(R.id.slide_menu_search);
		slide_menu_search.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent newIntent = new Intent(MainActivity.this,
						SearchActivity.class);
				startActivity(newIntent);
			}
		});

	}
	
	
	// 左右滑动刚好页面也有滑动效果  
    class MyGestureDetector extends SimpleOnGestureListener {  
        @Override  
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,  
                float velocityY) {  
            TabHost tabHost = getTabHost();  
            System.out.println("************");  
            try {  
                if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH)  
                    return false;  
                // right to left swipe  
                if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE  
                        && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {  
                    Log.i("test", "right");  
                    if (currentView == maxTabIndex) {  
                        currentView = 0;  
                    } else {  
                        currentView++;  
                    }  
                    tabHost.setCurrentTab(currentView);  
                } else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE  
                        && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {  
                    Log.i("test", "left");  
                    if (currentView == 0) {  
                        currentView = maxTabIndex;  
                    } else {  
                        currentView--;  
                    }  
                    tabHost.setCurrentTab(currentView);  
                }  
            } catch (Exception e) {  
            }  
            return false;  
        }  
    }  
  
    @Override  
    public boolean dispatchTouchEvent(MotionEvent event) {  
        if (gestureDetector.onTouchEvent(event)) {  
            event.setAction(MotionEvent.ACTION_CANCEL);  
        }  
        return super.dispatchTouchEvent(event);  
    }  
  
    @Override
	public boolean onTouchEvent(MotionEvent event) {
		// TODO Auto-generated method stub
		return gestureDetector.onTouchEvent(event);
	}
//    @Override  
//    public boolean onCreateOptionsMenu(Menu menu) {  
//        getMenuInflater().inflate(R.menu.activity_main, menu);  
//        return true;  
//    }  

}
  •   赞(3) 赞 +1 赞(3) 已赞
  •   收藏(18) 收藏 +1 已收藏 取消
  •   下载(2733)
评论(26)
大白兔很粘牙

大白兔很粘牙 2016-11-23 16:46:56

crunch错误怎么办呢
回复(0) 赞(0) 赞(1)
凸脑壳儿

凸脑壳儿 2016-04-23 10:15:05

学习一下,谢谢分享
回复(0) 赞(0) 赞(1)
shenweihua

shenweihua 2015-12-09 16:22:56

真心强大啊,哈哈
回复(0) 赞(0) 赞(1)
wufayuzhi

wufayuzhi 2015-11-09 21:15:59

最近我也要做这么那你的借鉴一下
回复(0) 赞(0) 赞(1)
wuxianai009

wuxianai009 2015-02-03 15:33:02

学习学习!感谢分享
回复(0) 赞(0) 赞(1)
  • 推荐
  • 审核
  • 收录
  • 获取活力值

源码上传作者

  • 6 能力值
  • 3 源码
  • 0 评测
  • 0 资料

热门源码