温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

visen动漫项目开发

发布时间:2020-06-27 15:40:16 来源:网络 阅读:368 作者:鹭明 栏目:开发技术

项目截图:

visen动漫项目开发





用到开源库:

lib_ABS

lib_download_fix

lib_material_helper

lib_material_menu

lib_material_menu_abs

lib_nineold_new

lib_ptr

lib_slideMenu

lib_vitamio_fix

lib_yuchen0505

SwitchButton


主要代码


MainActivity.java类

public class MainActivity extends SherlockFragmentActivity implements

OnItemClickListener, OnClickListener {

private boolean direction;


private DrawerLayout mDrawer;

private String[] list_name = new String[] { "品味动画", "分类浏览", "我的收藏", "我的下载" };

private int[] list_p_w_picpath = new int[] { R.drawable.drawer_all,

R.drawable.drawer_light, R.drawable.drawer_heart,

R.drawable.drawer_download };

private ActionBar actionBar;

private MaterialMenuView materialMenu;

    private boolean isNight;




@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

isNight=readMode();

if(isNight)

{

setTheme(R.style.night);

}

else {

setTheme(R.style.day);

}

setContentView(R.layout.activity_main);

findViewById(R.id.mode).setOnClickListener(this);

findViewById(R.id.set).setOnClickListener(this);

initCustomActionBar();

initDrawer();

addFirstFragment();

ImageLoaderUtils.readSetting(this);

}

private boolean readMode() {

SharedPreferences sp = getSharedPreferences("mode", MODE_PRIVATE);

boolean isnight = sp.getBoolean("isnight", false);

return isnight;

}

private void initCustomActionBar() {

actionBar = getSupportActionBar();

actionBar.setHomeButtonEnabled(false);

actionBar.setDisplayShowHomeEnabled(false);

actionBar.setDisplayShowTitleEnabled(false);

actionBar.setDisplayHomeAsUpEnabled(false);

actionBar.setDisplayShowCustomEnabled(true);

actionBar.setCustomView(R.layout.action_bar);

materialMenu = (MaterialMenuView) actionBar.getCustomView()

.findViewById(R.id.action_bar_menu);

materialMenu.setOnClickListener(this);

}


private void addFirstFragment() {

FragmentManager fm = getSupportFragmentManager();

FragmentTransaction ft = fm.beginTransaction();

ft.replace(R.id.container, new AnimeTasteFragment());

ft.commit();

}


private final class DrawerAdapter extends BaseAdapter {

@Override

public View getView(int position, View convertView, ViewGroup parent) {

View layout = getLayoutInflater().inflate(R.layout.listitem_menu,

null);

TextView tv_name = (TextView) layout.findViewById(R.id.textView1);

tv_name.setText(list_name[position]);

ImageView im_icon = (ImageView) layout

.findViewById(R.id.p_w_picpathView1);

im_icon.setImageResource(list_p_w_picpath[position]);

return layout;

}


@Override

public long getItemId(int position) {

// TODO Auto-generated method stub

return 0;

}


@Override

public Object getItem(int position) {

return null;

}


@Override

public int getCount() {

// TODO Auto-generated method stub

return 4;

}

}


class MyDrawerListener implements DrawerListener {

@Override

public void onDrawerStateChanged(int arg0) {

}


@Override

public void onDrawerSlide(View arg0, float slideOffset) {


materialMenu.setTransformationOffset(

MaterialMenuDrawable.AnimationState.BURGER_ARROW,

direction ? 2 - slideOffset : slideOffset);


}


@Override

public void onDrawerOpened(View arg0) {

direction = true;

}


@Override

public void onDrawerClosed(View arg0) {

direction = false;

}

}


private void initDrawer() {

findViewById(R.id.layout).setOnClickListener(new OnClickListener() {

@Override

public void onClick(View v) {

// TODO Auto-generated method stub

}

});

mDrawer = (DrawerLayout) findViewById(R.id.drawer);

mDrawer.setDrawerListener(new MyDrawerListener());

mDrawer.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

       

        

ListView drawerList = (ListView) findViewById(R.id.listView1);

drawerList.setOnItemClickListener(this);

drawerList.setAdapter(new DrawerAdapter());

}


@Override

public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {

case android.R.id.home:

IconState state = materialMenu.getState();

if (state == IconState.BURGER) {

mDrawer.openDrawer(Gravity.LEFT);

} else {

mDrawer.closeDrawer(Gravity.LEFT);

}


break;

default:

break;

}

return super.onOptionsItemSelected(item);

}


@Override

public boolean onCreateOptionsMenu(Menu menu) {

getSupportMenuInflater().inflate(R.menu.main, menu);

// getMenuInflater().inflate(R.menu.main, menu);

return true;

}


@Override

public void onItemClick(AdapterView<?> parent, View view, int position,

long id) {


Fragment fragment = null;

switch (position) {

case 0:

fragment = new AnimeTasteFragment();

break;

case 1:

fragment = new TypeFragment();

break;

case 2:

Intent intent=new Intent(this,Slide_MyfavorActivity.class);

startActivity(intent);

break;

case 3:

Intent intent2=new Intent(this,Slide_DownloadActivity.class);

startActivity(intent2);

break;


default:

break;

}

        if(fragment!=null)

        {

FragmentManager fm = getSupportFragmentManager();

FragmentTransaction ft = fm.beginTransaction();

ft.replace(R.id.container, fragment);

ft.commit();

        }


// 关闭侧滑菜单

mDrawer.closeDrawer(Gravity.LEFT);

        

}


@Override

public void onClick(View v) {


switch (v.getId()) {

case R.id.action_bar_menu:

IconState state = materialMenu.getState();

if (state == IconState.BURGER) {

mDrawer.openDrawer(Gravity.LEFT);

} else {

mDrawer.closeDrawer(Gravity.LEFT);

}

break;

case R.id.mode:

isNight=!isNight;

savaMode(isNight);

if(isNight)

{

setTheme(R.style.night);

}

else {

setTheme(R.style.day);

}

       finish();

       overridePendingTransition(0, 0);

       startActivity(new Intent(this,MainActivity.class));

 

break;

case R.id.set:


overridePendingTransition(0, 0);

       startActivity(new Intent(this,Slide_SettingActivity.class));

break;


default:

break;

}

}

private void savaMode(boolean isNight2) {

SharedPreferences sp = getSharedPreferences("mode", MODE_PRIVATE);

sp.edit().putBoolean("isnight", isNight2).commit();

}


}



Slide_MyfavorActivity.java类:

public class Slide_MyfavorActivity extends SherlockFragmentActivity implements

OnItemClickListener, OnClickListener ,com.xinbo.widget.ActionSheet.OnActionSheetSelected, OnCancelListener  {


private ActionBar actionBar;


private ListView listView;

List<AnimeCollect> mData = new ArrayList<AnimeCollect>();


private Myadpter adapter;


private BroadcastReceiver receiver=new BroadcastReceiver()

{


@Override

public void onReceive(Context context, Intent intent) {

readcache();

adapter.notifyDataSetChanged();

}

};

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_slidemyfavor);

initCustomActionBar();

IntentFilter filter=new IntentFilter();

filter.addAction(Constants.ACTION.UPDATA_FAVOR);

registerReceiver(receiver, filter);

readcache();

listView = (ListView) findViewById(R.id.listView1);

listView.setOnItemClickListener(new OnItemClickListener() {


@Override

public void onItemClick(AdapterView<?> arg0, View arg1,

int posion, long arg3) {

Intent intent=new Intent(Slide_MyfavorActivity.this,DetailActivity.class);

Anime info=new Anime(mData.get(posion).getid(), mData.get(posion).getAuthor(), mData.get(posion).getYear(), mData.get(posion).getDuration(), mData.get(posion).getVideoUrl(), mData.get(posion).getVideoSite(), 

mData.get(posion).getBrief(), mData.get(posion).getHomePic(), mData.get(posion).getDetailPic(), mData.get(posion).getName(), mData.get(posion).getVideoSource() );

intent.putExtra("guess", info);

startActivity(intent);

}

});

listView.setOnItemLongClickListener(new OnItemLongClickListener() {


@Override

public boolean onItemLongClick(AdapterView<?> arg0, View arg1,

int posion, long arg3) {

final AnimeCollect anime=mData.get(posion);

AlertDialog.Builder builder = new AlertDialog.Builder(Slide_MyfavorActivity.this);

builder.setTitle("提示");

builder.setMessage("确定要删除吗?");

builder.setNegativeButton("取消", null);

builder.setPositiveButton("确定",

new DialogInterface.OnClickListener() {


@Override

public void onClick(DialogInterface dialog, int which) {

DBManager.deleteCacheBytitle(anime);

readcache();

        adapter.notifyDataSetChanged();

        

       

}

});

AlertDialog create = builder.create();

create.show();

return false;

}

});

        adapter = new Myadpter();

        listView.setAdapter(adapter);

        

}


private void readcache() {

mData.clear();

mData = new Select().from(AnimeCollect.class).execute();

}

//接受广播

@Override

protected void onDestroy() {

unregisterReceiver(receiver);

super.onDestroy();

}


class Myadpter extends BaseAdapter

{


@Override

public int getCount() {

// TODO Auto-generated method stub

return mData.size();

}


@Override

public Object getItem(int position) {

// TODO Auto-generated method stub

return null;

}


@Override

public long getItemId(int position) {

// TODO Auto-generated method stub

return 0;

}


@Override

public View getView(int position, View convertView, ViewGroup parent) {

View layout = null;

viewHold vHold = null;


if (convertView == null) {

layout =getLayoutInflater().inflate(

R.layout.listitem_guess, null);

ImageView p_w_picpathView = (ImageView) layout

.findViewById(R.id.p_w_picpathView1);

TextView tv_title = (TextView) layout

.findViewById(R.id.tv_title);

TextView tv_subtitle = (TextView) layout

.findViewById(R.id.tv_subtitle);

vHold = new viewHold(p_w_picpathView, tv_title, tv_subtitle);

layout.setTag(vHold);

} else {


layout = convertView;

vHold = (viewHold) layout.getTag();

}

AnimeCollect anime = mData.get(position);

vHold.tv_title.setText(anime.getName());

vHold.tv_subtitle.setText(anime.getBrief());

//UILUtils.displayImage(anime.getHomePic(), vHold.p_w_picpathView);

ImageLoaderUtils.displayImage(Slide_MyfavorActivity.this,anime.getHomePic(), vHold.p_w_picpathView);

return layout;

}

}

class viewHold {

ImageView p_w_picpathView;

TextView tv_title;

TextView tv_subtitle;


public viewHold(ImageView p_w_picpathView, TextView tv_title,

TextView tv_subtitle) {

super();

this.p_w_picpathView = p_w_picpathView;

this.tv_title = tv_title;

this.tv_subtitle = tv_subtitle;

}


}

private void initCustomActionBar() {

actionBar = getSupportActionBar();

actionBar.setHomeButtonEnabled(false);

actionBar.setDisplayShowHomeEnabled(false);

actionBar.setDisplayShowTitleEnabled(false);

actionBar.setDisplayHomeAsUpEnabled(false);

actionBar.setDisplayShowCustomEnabled(true);

actionBar.setCustomView(R.layout.action_bar);

MaterialMenuView materialMenu = (MaterialMenuView) actionBar.getCustomView()

.findViewById(R.id.action_bar_menu);

materialMenu.setOnClickListener(this);


}

@Override

public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {

case android.R.id.home:

finish();

break;

case R.id.menu_delete:

ActionSheet.showSheet(Slide_MyfavorActivity.this, Slide_MyfavorActivity.this, Slide_MyfavorActivity.this);

         

break;

default:

break;

}

return super.onOptionsItemSelected(item);

}


@Override

public boolean onCreateOptionsMenu(Menu menu) {

getSupportMenuInflater().inflate(R.menu.slidemyfavor, menu);

return true;

}


@Override

public void onClick(View v) {

if (v.getId() == R.id.action_bar_menu) {

finish();

}

}


@Override

public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {


}


@Override

public void onCancel(DialogInterface dialog) {

// TODO Auto-generated method stub

}


@Override

public void onClick(int whichButton) {

switch (whichButton) {

case 0:

DBManager.deleteCache();

        adapter.notifyDataSetChanged();

        mData.clear();

break;


case 1:

break;


default:

break;

}

}


}


Slide_DownloadActivity类:

public class Slide_DownloadActivity extends SherlockFragmentActivity implements

OnItemClickListener, OnClickListener ,com.xinbo.widget.ActionSheet.OnActionSheetSelected, OnCancelListener {


private ActionBar actionBar;

private Myreceiver mReceiver=new Myreceiver();

private ListView listView;

List<AnimeDownload> mData = new ArrayList<AnimeDownload>();


private Myadpter adapter;


class Myreceiver extends BroadcastReceiver {


@Override

public void onReceive(Context context, Intent intent) {

handleIntent(intent);


}


private void handleIntent(Intent intent) {


if (intent != null

&& intent

.getAction()

.equals("com.yyxu.download.activities.DownloadListActivity")) {

int type = intent.getIntExtra(MyIntents.TYPE, -1);

String url;


switch (type) {


case MyIntents.Types.PROCESS:

url = intent.getStringExtra(MyIntents.URL);

String progress = intent

.getStringExtra(MyIntents.PROCESS_PROGRESS);   

int first = listView.getFirstVisiblePosition();

int count = listView.getChildCount();

for (int i = 0; i < count; i++) {

AnimeDownload info = mData.get(i + first);

// if (info.getVideoUrl().equals(url)){

View layout = listView.getChildAt(i);

TextView tvProgress = (TextView) layout

.findViewById(R.id.tv_sped);

tvProgress.setText(progress+"%");

// return;

// }

}


break;


default:

break;

}

}

}

}


@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_slidedownload);

initCustomActionBar();

readcache();

initListview();

register();

}


private void initListview() {

listView = (ListView) findViewById(R.id.listView1);

listView.setOnItemClickListener(new OnItemClickListener() {


@Override

public void onItemClick(AdapterView<?> arg0, View arg1, int posion,

long arg3) {

Intent intent = new Intent(Slide_DownloadActivity.this,

DetailActivity.class);

Anime info = new Anime(mData.get(posion).getid(), mData.get(

posion).getAuthor(), mData.get(posion).getYear(), mData

.get(posion).getDuration(), mData.get(posion)

.getVideoUrl(), mData.get(posion).getVideoSite(), mData

.get(posion).getBrief(),

mData.get(posion).getHomePic(), mData.get(posion)

.getDetailPic(), mData.get(posion).getName(),

mData.get(posion).getVideoSource());

intent.putExtra("guess", info);

startActivity(intent);


}


});

listView.setOnItemLongClickListener(new OnItemLongClickListener() {


@Override

public boolean onItemLongClick(AdapterView<?> arg0, View arg1,

int posion, long arg3) {


final AnimeDownload anime = mData.get(posion);

AlertDialog.Builder builder = new AlertDialog.Builder(

Slide_DownloadActivity.this);

builder.setTitle("提示");

builder.setMessage("确定要删除吗?");

builder.setNegativeButton("取消", null);

builder.setPositiveButton("确定",

new DialogInterface.OnClickListener() {


@Override

public void onClick(DialogInterface dialog,

int which) {


DBManager.deletedownBytitle(anime);

readcache();

adapter.notifyDataSetChanged();


}

});

AlertDialog create = builder.create();

create.show();


return false;

}


});

adapter = new Myadpter();

listView.setAdapter(adapter);

}


private void register() {

IntentFilter filter = new IntentFilter();

filter.addAction("com.yyxu.download.activities.DownloadListActivity");

registerReceiver(mReceiver, filter);


}


private void readcache() {

mData.clear();

mData = new Select().from(AnimeDownload.class).execute();


}


@Override

protected void onDestroy() {


super.onDestroy();

if(mReceiver!=null)

{

unregisterReceiver(mReceiver);

}

}


class Myadpter extends BaseAdapter {


@Override

public int getCount() {

// TODO Auto-generated method stub

return mData.size();

}


@Override

public Object getItem(int position) {

// TODO Auto-generated method stub

return null;

}


@Override

public long getItemId(int position) {


return 0;

}


@Override

public View getView(int position, View convertView, ViewGroup parent) {


View layout = null;

viewHold vHold = null;


if (convertView == null) {

layout = getLayoutInflater().inflate(R.layout.listitem_guess,

null);

ImageView p_w_picpathView = (ImageView) layout

.findViewById(R.id.p_w_picpathView1);

TextView tv_title = (TextView) layout

.findViewById(R.id.tv_title);

TextView tv_subtitle = (TextView) layout

.findViewById(R.id.tv_subtitle);

TextView tv_sped = (TextView) layout.findViewById(R.id.tv_sped);

tv_sped.setVisibility(View.VISIBLE);

vHold = new viewHold(p_w_picpathView, tv_title, tv_subtitle, tv_sped);

layout.setTag(vHold);

} else {


layout = convertView;

vHold = (viewHold) layout.getTag();

}

AnimeDownload anime = mData.get(position);

vHold.tv_title.setText(anime.getName());

vHold.tv_subtitle.setText(anime.getBrief());

//UILUtils.displayImage(anime.getHomePic(), vHold.p_w_picpathView);

            ImageLoaderUtils.displayImage(Slide_DownloadActivity.this,anime.getHomePic(), vHold.p_w_picpathView);

return layout;

}


}


class viewHold {

ImageView p_w_picpathView;

TextView tv_title;

TextView tv_subtitle;

TextView tv_sped;


public viewHold(ImageView p_w_picpathView, TextView tv_title,

TextView tv_subtitle, TextView tv_sped) {

super();

this.p_w_picpathView = p_w_picpathView;

this.tv_title = tv_title;

this.tv_subtitle = tv_subtitle;

this.tv_sped = tv_sped;

}


}


private void initCustomActionBar() {

actionBar = getSupportActionBar();

actionBar.setHomeButtonEnabled(false);

actionBar.setDisplayShowHomeEnabled(false);

actionBar.setDisplayShowTitleEnabled(false);

actionBar.setDisplayHomeAsUpEnabled(false);

actionBar.setDisplayShowCustomEnabled(true);

actionBar.setCustomView(R.layout.action_bar);

MaterialMenuView materialMenu = (MaterialMenuView) actionBar

.getCustomView().findViewById(R.id.action_bar_menu);

materialMenu.setOnClickListener(this);


}



@Override

public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {

case android.R.id.home:

finish();

break;

case R.id.menu_delete:


ActionSheet.showSheet(Slide_DownloadActivity.this, Slide_DownloadActivity.this, Slide_DownloadActivity.this);


break;

default:

break;

}

return super.onOptionsItemSelected(item);

}


@Override

public boolean onCreateOptionsMenu(Menu menu) {

getSupportMenuInflater().inflate(R.menu.slidemyfavor, menu);

return true;

}


@Override

public void onClick(View v) {

if (v.getId() == R.id.action_bar_menu) {

finish();

}

}


@Override

public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {


}


@Override

public void onCancel(DialogInterface dialog) {

// TODO Auto-generated method stub

}


@Override

public void onClick(int whichButton) {

switch (whichButton) {

case 0:

DBManager.deletedownCache();

adapter.notifyDataSetChanged();

mData.clear();

break;


case 1:

break;


default:

break;

}


}

}



DetailActivity类:


public class DetailActivity extends SherlockFragmentActivity implements

OnItemClickListener, OnClickListener {


private ActionBar actionBar;

private Anime anime;

private boolean mFavor;

private VideoView mVideoView;

private ProgressBar progressBar;

private ImageView img_play;


private TextView tv_title;

private TextView tv_author;

private TextView tv_content;

ArrayList<Anime> mData = new ArrayList<Anime>();

private ListView dlListView;

private ScrollView scrollView;

private Myadpter adpter;


private MediaController controller;

private Mybinder mBinder;

private boolean isFisrt;

private ServiceConnection mConn = new ServiceConnection() {


public void onServiceDisconnected(ComponentName name) {

}


public void onServiceConnected(ComponentName name, IBinder service) {

mBinder = (Mybinder) service;


}

};


@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

if (!LibsChecker.checkVitamioLibs(this)) {

return;

}

setContentView(R.layout.activity_detail);

Intent intent = getIntent();

anime = (Anime) intent.getParcelableExtra("guess");

initCustomActionBar();

isFisrt = readmode();

initdetaiData();

progressBar = (ProgressBar) findViewById(R.id.progressBar1);

progressBar.setVisibility(View.INVISIBLE);

img_play = (ImageView) findViewById(R.id.btn_play);

mVideoView = (VideoView) findViewById(R.id.video_view);

controller = new MediaController(this);

mVideoView.setMediaController(controller);

mVideoView.requestFocus();

mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

@Override

public void onPrepared(MediaPlayer mediaPlayer) {

// optional need Vitamio 4.0

mediaPlayer.setPlaybackSpeed(1.0f);

progressBar.setVisibility(View.INVISIBLE);


}

});


dlListView = (ListView) findViewById(R.id.listView2);

scrollView = (ScrollView) findViewById(R.id.scrollView1);

tv_title = (TextView) findViewById(R.id.tv_title);

tv_author = (TextView) findViewById(R.id.tv_author);

tv_content = (TextView) findViewById(R.id.tv_content);

adpter = new Myadpter();

dlListView.setAdapter(adpter);

dlListView.setOnItemClickListener(new OnItemClickListener() {


@Override

public void onItemClick(AdapterView<?> arg0, View arg1,

int positon, long arg3) {

Intent intent = new Intent(DetailActivity.this,

DetailActivity.class);

intent.putExtra("guess", mData.get(positon));

startActivity(intent);


}

});

tv_title.setText(anime.getName());

tv_author.setText(anime.getAuthor() + "." + anime.getYear());

tv_content.setText(anime.getBrief());

mFavor = DBManager.isFavor(anime);

scrollView.smoothScrollTo(0, 0);

}


private boolean readmode() {

SharedPreferences sp = getSharedPreferences("first", MODE_PRIVATE);

boolean isFirst = sp.getBoolean("isfirst", false);

return isFirst;

}


public void editdilog(View v) {

AlertDialog.Builder builder = new AlertDialog.Builder(this);

builder.setTitle("请写下你的感受");

View view = getLayoutInflater().inflate(R.layout.editview2, null);

builder.setView(view);

builder.setNegativeButton("取消", null);

builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {


@Override

public void onClick(DialogInterface dialog, int which) {


}

});

AlertDialog create = builder.create();

create.show();


}


private void savaMode(boolean isfirst) {

SharedPreferences sp = getSharedPreferences("first", MODE_PRIVATE);

sp.edit().putBoolean("isfirst", isfirst).commit();

}


public void btnPlay(View v) {

img_play.setVisibility(View.INVISIBLE);

progressBar.setVisibility(View.VISIBLE);

isFisrt = !isFisrt;

savaMode(isFisrt);

if (isFisrt) {


mVideoView

.setVideoPath("http://xinbo.qiniudn.com/videoviewdemo.mp4");

controller.setAnchorView(mVideoView);

} else {


Intent intent = new Intent(this, VideoWebviewActivity.class);

String videourl = anime.getVideoUrl();

Log.e("videourl", videourl);

intent.putExtra("Videourl", videourl);

startActivity(intent);

}


}


private void initdetaiData() {


ApiConnector.getInstance(this).getRandom(5, new VolleyListener() {


@Override

public void onErrorResponse(VolleyError arg0) {

// TODO Auto-generated method stub


}


@Override

public void onResponse(String response) {

// TODO Auto-generated method stub

mData.clear();

Init init = GsonUtils.parseJSON(response, Init.class);

mData = init.getData().getList().getAnime();

adpter.notifyDataSetChanged();


}

});

}


class Myadpter extends BaseAdapter {


@Override

public int getCount() {

// TODO Auto-generated method stub

return mData.size();

}


@Override

public Object getItem(int arg0) {

// TODO Auto-generated method stub

return null;

}


@Override

public long getItemId(int arg0) {

// TODO Auto-generated method stub

return 0;

}


@Override

public View getView(int position, View convertView, ViewGroup arg2) {

View layout = null;

viewHold vHold = null;


if (convertView == null) {

layout = getLayoutInflater().inflate(R.layout.listitem_guess,

null);

ImageView p_w_picpathView = (ImageView) layout

.findViewById(R.id.p_w_picpathView1);

TextView tv_title = (TextView) layout

.findViewById(R.id.tv_title);

TextView tv_subtitle = (TextView) layout

.findViewById(R.id.tv_subtitle);

vHold = new viewHold(p_w_picpathView, tv_title, tv_subtitle);

layout.setTag(vHold);

} else {


layout = convertView;

vHold = (viewHold) layout.getTag();

}

Anime anime = mData.get(position);

vHold.tv_title.setText(anime.getName());

vHold.tv_subtitle.setText(anime.getBrief());

//UILUtils.displayImage(anime.getHomePic(), vHold.p_w_picpathView);

            ImageLoaderUtils.displayImage(DetailActivity.this, anime.getHomePic(), vHold.p_w_picpathView);

return layout;


}


}


class viewHold {

ImageView p_w_picpathView;

TextView tv_title;

TextView tv_subtitle;


public viewHold(ImageView p_w_picpathView, TextView tv_title,

TextView tv_subtitle) {

super();

this.p_w_picpathView = p_w_picpathView;

this.tv_title = tv_title;

this.tv_subtitle = tv_subtitle;

}


}


private void initCustomActionBar() {

actionBar = getSupportActionBar();

actionBar.setHomeButtonEnabled(false);

actionBar.setDisplayShowHomeEnabled(false);

actionBar.setDisplayShowTitleEnabled(false);

actionBar.setDisplayHomeAsUpEnabled(false);

actionBar.setDisplayShowCustomEnabled(true);

actionBar.setCustomView(R.layout.action_bar);

MaterialMenuView materialMenu = (MaterialMenuView) actionBar

.getCustomView().findViewById(R.id.action_bar_menu);

materialMenu.setOnClickListener(this);


}


@Override

public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {

case android.R.id.home:

finish();

break;

case R.id.menu_favor:

if (mFavor) {

mFavor = false;

item.setIcon(R.drawable.ic_action_action_favorite_outline);

DBManager.cancelFavor(anime);

ToastUtils.showToast(this, "取消收藏");


// 发送广播

Intent intent = new Intent();

intent.setAction(Constants.ACTION.UPDATA_FAVOR);

sendBroadcast(intent);


} else {

DBManager.addFavorToCache(anime);

ToastUtils.showToast(this, "收藏成功");


item.setIcon(R.drawable.ic_action_action_favorite);

mFavor = true;

Intent intent = new Intent();

intent.setAction(Constants.ACTION.UPDATA_FAVOR);

sendBroadcast(intent);

}


break;

case R.id.menu_download:

downLoad();


break;

default:

break;

}

return super.onOptionsItemSelected(item);

}


private void downLoad() {


if (mBinder != null) {

mBinder.download(anime.getName());

}

DBManager.addDownloadToCache(anime);


}


@Override

protected void onStart() {

super.onStart();

// 启动NotifiService更新通知

Intent intent = new Intent(this, NotifyService.class);

startService(intent);

bindService(intent, mConn, Context.BIND_AUTO_CREATE);

}


@Override

protected void onStop() {

super.onStop();

unbindService(mConn);

}


@Override

public boolean onPrepareOptionsMenu(Menu menu) {

MenuItem item = menu.getItem(0);

if (mFavor) {

item.setIcon(R.drawable.ic_action_action_favorite);

}

return super.onPrepareOptionsMenu(menu);

}


@Override

public boolean onCreateOptionsMenu(Menu menu) {

getSupportMenuInflater().inflate(R.menu.detail, menu);

return true;

}


@Override

public void onClick(View v) {


if (v.getId() == R.id.action_bar_menu) {

finish();

}

}


@Override

public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {


}


}


Slide_SettingActivity类:

public class Slide_SettingActivity extends SherlockFragmentActivity implements

OnItemClickListener, OnClickListener {


private Myadpter adapter;

private ActionBar actionBar;

private ListView listView;

private String[] name = new String[] { "Only for Wife", "高清视频", "字体大小",

"清空缓存", "检查更新", "推荐给小伙伴", "为我们评分" };


@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_slidedownload);

initCustomActionBar();


initListview();


}


private void initListview() {

listView = (ListView) findViewById(R.id.listView1);

listView.setOnItemClickListener(this);

adapter = new Myadpter();

listView.setAdapter(adapter);

}


@Override

protected void onDestroy() {


super.onDestroy();


}


class Myadpter extends BaseAdapter {


@Override

public int getCount() {

// TODO Auto-generated method stub

return name.length;

}


@Override

public Object getItem(int position) {

// TODO Auto-generated method stub

return null;

}


@Override

public long getItemId(int position) {


return 0;

}


@Override

public View getView(int position, View convertView, ViewGroup parent) {

View layout = getLayoutInflater().inflate(

R.layout.listitem_setting, null);

TextView mtextView = (TextView) layout.findViewById(R.id.textView1);

ImageView p_w_picpathView = (ImageView) layout

.findViewById(R.id.p_w_picpathView1);

SwitchButton mSwitch = (SwitchButton) layout

.findViewById(R.id.sb_default);

if (position == 0) {

p_w_picpathView.setVisibility(View.INVISIBLE);

mSwitch.setVisibility(View.VISIBLE);

SharedPreferences sp = getSharedPreferences("setting",

Context.MODE_PRIVATE);

boolean isWifiOnly = sp.getBoolean("IS_WIFI_ONLY", false);

if (isWifiOnly) {

mSwitch.setChecked(true);

} else {

mSwitch.setChecked(false);

}

mSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

@Override

public void onCheckedChanged(CompoundButton arg0, boolean checked) {

SharedPreferences sp = getSharedPreferences("setting",

Context.MODE_PRIVATE);

if(checked)

{

sp.edit().putBoolean("IS_WIFI_ONLY", true).commit();

}

else {

sp.edit().putBoolean("IS_WIFI_ONLY", false).commit();

}

ImageLoaderUtils.readSetting(Slide_SettingActivity.this);

}

});


}

if (position == 1) {

p_w_picpathView.setVisibility(View.INVISIBLE);

mSwitch.setVisibility(View.VISIBLE);


}


mtextView.setText(name[position]);

return layout;


}

}


private void initCustomActionBar() {

actionBar = getSupportActionBar();

actionBar.setHomeButtonEnabled(false);

actionBar.setDisplayShowHomeEnabled(false);

actionBar.setDisplayShowTitleEnabled(false);

actionBar.setDisplayHomeAsUpEnabled(false);

actionBar.setDisplayShowCustomEnabled(true);

actionBar.setCustomView(R.layout.action_bar);

MaterialMenuView materialMenu = (MaterialMenuView) actionBar

.getCustomView().findViewById(R.id.action_bar_menu);

materialMenu.setOnClickListener(this);


}


@Override

public boolean onOptionsItemSelected(MenuItem item) {


return super.onOptionsItemSelected(item);


}


@Override

public boolean onCreateOptionsMenu(Menu menu) {


getSupportMenuInflater().inflate(R.menu.slidesetting, menu);

return true;

}


@Override

public void onClick(View v) {

if (v.getId() == R.id.action_bar_menu) {

finish();

}

}


@Override

public void onItemClick(AdapterView<?> arg0, View arg1, int posion,

long arg3) {


switch (posion) {


case 2:

editdilog();


break;

case 3:

clearCache();


break;

case 4:

upVersion();

break;

case 6:

Intent intent = new Intent(Intent.ACTION_VIEW);

intent.setData(Uri.parse("market://details?id="

+ "com.lashou.groupurchasing"));

startActivity(intent);


break;


default:

break;

}


}


private void clearCache() {

AlertDialog.Builder builder = new AlertDialog.Builder(

Slide_SettingActivity.this);

builder.setTitle("提示");

builder.setMessage("确定要清空吗?");

builder.setNegativeButton("取消", null);

builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {


@Override

public void onClick(DialogInterface dialog, int which) {


}

});

AlertDialog create = builder.create();

create.show();

}


private void upVersion() {

String url = "http://7xj77y.com1.z0.glb.clouddn.com/upgrade.txt";

HTTPUtils.get(this, url, new VolleyListener() {

public void onErrorResponse(VolleyError arg0) {

}


public void onResponse(String response) {

VersionInfo verInfo = GsonUtils.parseJSON(response,

VersionInfo.class);

int currVersion = getCurrVersion();

if (verInfo.new_version > currVersion) {

// json

UpgradeDialogFragment dlg = new UpgradeDialogFragment();

dlg.setVersionInfo(verInfo);

dlg.show(getSupportFragmentManager(), null);

}

}

});

}


public int getCurrVersion() {

PackageManager pm = this.getPackageManager();

try {

PackageInfo packageInfo = pm.getPackageInfo(this.getPackageName(),

0);

return packageInfo.versionCode;

} catch (NameNotFoundException e) {

}

return 0;

}


public void editdilog() {

AlertDialog.Builder builder = new AlertDialog.Builder(this);

builder.setTitle("请选择字体大小");

View view = getLayoutInflater().inflate(R.layout.editview, null);

builder.setView(view);

builder.setNegativeButton("取消", null);

builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {


@Override

public void onClick(DialogInterface dialog, int which) {


}

});

AlertDialog create = builder.create();

create.show();


}


}


SplashActivity类:

public class SplashActivity extends Activity {


@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_splash);


new Handler().postDelayed(new Runnable() {


@Override

public void run() {

startActivity(new Intent(SplashActivity.this,

MainActivity.class));

finish();

}

}, 2000);

}


@Override

public boolean onCreateOptionsMenu(Menu menu) {

getMenuInflater().inflate(R.menu.splash, menu);

return true;

}


}


VideoWebviewActivity类:

public class VideoWebviewActivity extends SherlockFragmentActivity implements  OnClickListener{


    private WebView mWebView;


private ActionBar actionBar;

private MaterialMenuView materialMenu;


private ProgressBar mProgressBar;


@Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.webview);

        initCustomActionBar();

        initWebview();

    }

private void initCustomActionBar() {

actionBar = getSupportActionBar();

actionBar.setHomeButtonEnabled(false);

actionBar.setDisplayShowHomeEnabled(false);

actionBar.setDisplayShowTitleEnabled(false);

actionBar.setDisplayHomeAsUpEnabled(false);

actionBar.setDisplayShowCustomEnabled(true);

actionBar.setCustomView(R.layout.action_bar);

materialMenu = (MaterialMenuView) actionBar.getCustomView()

.findViewById(R.id.action_bar_menu);

materialMenu.setOnClickListener(this);

}


    private void initWebview() {

mWebView = (WebView) findViewById(R.id.webView1);

mProgressBar = (ProgressBar) findViewById(R.id.progressBar1);

Intent intent = getIntent();

String url=intent.getStringExtra("Videourl");

WebSettings settings = mWebView.getSettings();

settings.setJavaScriptEnabled(true);

mWebView.setWebViewClient(new WebViewClient());

mWebView.setWebChromeClient(new WebChromeClient(){

@Override

public void onProgressChanged(WebView view, int newProgress) {

// TODO Auto-generated method stub

super.onProgressChanged(view, newProgress);

if(newProgress==100)

{

mProgressBar.setVisibility(View.INVISIBLE);

}

else {

mProgressBar.setVisibility(View.VISIBLE);

mProgressBar.setProgress(newProgress);

}

}

});

mWebView.loadUrl(url);

}



@Override

public void onClick(View v) {

if (v.getId() == R.id.action_bar_menu) {

finish();

}

}

    

}


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI