溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

仿途牛旅游APP項(xiàng)目開發(fā)

發(fā)布時(shí)間:2020-07-05 19:58:22 來源:網(wǎng)絡(luò) 閱讀:955 作者:鷺明 欄目:移動(dòng)開發(fā)

仿途牛旅游APP項(xiàng)目開發(fā)

仿途牛旅游APP項(xiàng)目開發(fā)


用到的庫有:

android-support-v7-appcompat

android-support-v7recyclerview

drawee

fbcore

fresco

FruitShop

p_w_picpathpipeline

p_w_picpathpipeline-base

p_w_picpathpipeline-okhttp

lib_BarCode

lib_CountdownView

lib_Mob_SMSSDK

lib_PullToRefresh_niu

lib_ViewPagerIndicator

lib_Weibo

lib_yuchen0612_bmobcompat

static-webp



主要代碼:


public class FirstActivity extends FragmentActivity

{

private LinearLayout firstlin;


@Override

protected void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_first);

firstlin = (LinearLayout) findViewById(R.id.firstlinear);

firstlin.postDelayed(new Runnable() 

{

public void run()

{

   firstlin.setVisibility(View.VISIBLE);

   firstlin.postDelayed(new Runnable()

{

public void run()

{

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

FirstActivity.this.finish();

}

}, 3000);

}

}, 3000)

;

}

}


public class MainActivity extends FragmentActivity

{                                                          

private FragmentTabHost mTabHost;

@Override           

protected void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);

setContentView(R.layout.fragment_main);

mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);

mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);

mTabHost.addTab(mTabHost.newTabSpec("home").

setIndicator(getTabIndicator("首頁", R.drawable.selector_home)),

HomeFragment.class, null);

mTabHost.addTab(mTabHost.newTabSpec("destination").

setIndicator(getTabIndicator("目的地", R.drawable.selector_dest)), 

DestinationFragment.class, null);

mTabHost.addTab(mTabHost.newTabSpec("found").

setIndicator(getTabIndicator("發(fā)現(xiàn)", R.drawable.selector_found)),

FoundFragment.class, null);

mTabHost.addTab(mTabHost.newTabSpec("trip").

setIndicator(getTabIndicator("行程玩法", R.drawable.selector_trip)), 

TripFragment.class, null);

mTabHost.addTab(mTabHost.newTabSpec("my").

setIndicator(getTabIndicator("我的", R.drawable.selector_my)), 

MyFragment.class, null);

}

@SuppressLint("ResourceAsColor")

protected View getTabIndicator(String title,int id)

{

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

TextView tv = (TextView) layout.findViewById(R.id.bottom_tv);

tv.setText(title); 

ImageView img = (ImageView) layout.findViewById(R.id.bottom_img);

img.setImageResource(id); 

return layout; 

}

}



public class LogInActivity extends WeiboSSOActivity implements OnClickListener

{

private SharedPreferences sp;

private EditText user;

private EditText password;

private Editor edit;

@Override

public void finish()

{

super.finish();

overridePendingTransition(0, R.anim.tween_slide_out);

}

@Override

public void onClick(View v)

{

switch (v.getId())

{

case R.id.bt_login_back:// 退出

LogInActivity.this.finish();

break;

case R.id.iv_partner_sina:// 微博

wbLogin();

edit.putBoolean("user",false); 

edit.commit();

LogInActivity.this.finish();

break;

case R.id.login_submit:// 微博

String uname = user.getText().toString(); 

String pw = password.getText().toString(); 

if(uname.equals("visen")&&pw.equals("123456"))

{

Toast.makeText(this, "登錄成功",Toast.LENGTH_SHORT).show();

edit.putBoolean("user",true); 

edit.commit();

LogInActivity.this.finish();

}else

{

edit.putBoolean("user",false); 

edit.commit();

Toast.makeText(this, "用戶或密碼錯(cuò)誤",Toast.LENGTH_SHORT).show();

}

break;

default:

break;

}

}

@Override

protected int getLayoutID()

{

return R.layout.activity_login;

}

@Override

protected void initUI()

{

sp = getSharedPreferences("data", 0);

edit = sp.edit(); 

user = (EditText) findViewById(R.id.login_id);

password = (EditText) findViewById(R.id.login_password);

Button submit = (Button) findViewById(R.id.login_submit);

ImageView back = (ImageView) findViewById(R.id.bt_login_back);

ImageView sina = (ImageView) findViewById(R.id.iv_partner_sina);

back.setOnClickListener(this);

sina.setOnClickListener(this);

submit.setOnClickListener(this);

}

@SuppressLint("CommitPrefEdits")

@Override

protected void getToken(String token)

{

edit.putString("token", getToken());

edit.putString("uid", getUid());

edit.commit();

}

}



public class DetileActivity extends FragmentActivity {

String str = "<昆大麗-香格里拉雙飛8日游>家庭立減600元,騎行雙廊,好評(píng)如潮,玉龍雪山普達(dá)措,贈(zèng)溫泉";

private ViewPager pager_detile;

private MyAdapter myAdapter;

private List<DefaultJourneyDetail> JourneyDetails;


@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_detile);

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

tv_detile_title.setText(str);

iniData();

iniPaper();

iniListview();

}

private void iniData() {

ApiClient.getDetilelist(this, new ResponseListener() {

@Override

public void onResponse(String arg0) {

Detile detile = GsonUtils.parseJSON(arg0, Detile.class);

Data data = detile.getData();

List<JourneyDetailList> journeyDetailList = data.getJourneyDetailList();

JourneyDetails = journeyDetailList.get(0).getDefaultJourneyDetail();

}

@Override

public void onErrorResponse(VolleyError arg0) {

}

});

}


private void iniListview() 

{

ListView4ScrollView list_detile = (ListView4ScrollView) findViewById(R.id.list_detile);

myAdapter = new MyAdapter();

list_detile.setAdapter(myAdapter);

}

class MyAdapter extends BaseAdapter{


@Override

public int getCount() {

if (JourneyDetails != null) {

return JourneyDetails.size();

}

return 0;

}


@Override

public Object getItem(int arg0) {

return null;

}


@Override

public long getItemId(int arg0) {

return 0;

}


@SuppressLint({ "ViewHolder", "InflateParams" })

@Override

public View getView(int position, View arg1, ViewGroup arg2) 

{

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

TextView day = (TextView) inflate.findViewById(R.id.tv_day);

TextView food = (TextView) inflate.findViewById(R.id.tv_food);

TextView stay = (TextView) inflate.findViewById(R.id.tv_stay);

DefaultJourneyDetail defaultJourneyDetail2 = JourneyDetails.get(position);

day.setText(defaultJourneyDetail2.getJourneyName()+defaultJourneyDetail2.getJourneyDescription());

food.setText(defaultJourneyDetail2.getFoodAndStays().getFood());

stay.setText("住宿:"+defaultJourneyDetail2.getFoodAndStays().getStay());

return inflate;

}

}



private void iniPaper() {

pager_detile = (ViewPager)findViewById(R.id.pager_detile);

FragmentManager fm = getSupportFragmentManager();

PaperDetileAdapter paperAdapter = new PaperDetileAdapter(fm);

pager_detile.setAdapter(paperAdapter);

}

class PaperDetileAdapter extends FragmentStatePagerAdapter{


public PaperDetileAdapter(FragmentManager fm) {

super(fm);

}


@Override

public Fragment getItem(int position) {

return new DetileChildFragment(position);

}


@Override

public int getCount() {

return 5;

}

}


}



public class BarCodeActivity extends Activity

{

private TextView mTextView;



@Override

protected void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_bar_code);

mTextView = (TextView) findViewById(R.id.barcode_tv);

Intent openCameraIntent = new Intent(this, CaptureActivity.class);

startActivityForResult(openCameraIntent, 0); 

}

public void barCodeCanle(View v)

{

BarCodeActivity.this.finish();

 

}

@Override

protected void onActivityResult(int requestCode, int resultCode, Intent data)

{

// 處理掃描結(jié)果(在界面上顯示)

if (resultCode == RESULT_OK) {

Bundle bundle = data.getExtras();

String scanResult = bundle.getString("result");

mTextView.setText(scanResult);

}

}

}



public class SearchActivity extends Activity implements OnClickListener

{

private TextView cancle;

private TabHost mTabHost;

private ListView searchlv;

private TextView titleTv;

private EditText titleEdit;

private TextView showTv;

private List<Allcity> mAllcityList=new ArrayList<Allcity>();

private List<Hotcity> mHotcityList=new ArrayList<Hotcity>();

private ArrayList<String> mLetter=new ArrayList<String>();

private ArrayList<String> mSearchList=new ArrayList<String>();

private LetterView letterView;

private Runnable rn;

private MyAdapter myAdapter;

private ListView lvJing;

private GridHotAdapter hotAdapter;

private SearchAdapter searchAdapter;





@Override

protected void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_search);

initData();

initLetterView();

initTabHost();

initControlView();

}



private void initData()

{

ApiClient.getSearch(this, new ResponseListener()

{

@Override

public void onResponse(String arg0)

{

Cities cities = GsonUtils.parseJSON(arg0, Cities.class); 

List<Hotcity> hotcity = cities.getHotcity();

mHotcityList.clear();

mHotcityList.addAll(hotcity);

List<Allcity> allcity = cities.getAllcity();

mAllcityList.clear();

mAllcityList.addAll(allcity);

hotAdapter.notifyDataSetChanged();

myAdapter.notifyDataSetChanged();

addLetter(allcity);

letterView.setLetter(mLetter);

}


@Override

public void onErrorResponse(VolleyError arg0)

{

Log.e("網(wǎng)絡(luò)下載失敗", "網(wǎng)絡(luò)下載失敗");

}

});

}


private void addLetter(List<Allcity> allcity)

{

mLetter.add("推薦");

mLetter.add("歷史");

mLetter.add("熱門");

for(int i=0;i<allcity.size();i++)

{

Allcity all = allcity.get(i); 

String letter = getLetter(all); 

if(!mLetter.contains(letter))

{

mLetter.add(letter);

}

}

}




@SuppressLint("DefaultLocale")

private String getLetter(Allcity all)

{

String pinyin = all.getPinyin();

String letter = pinyin.substring(0, 1).toUpperCase();

return letter; 

}



private void initControlView()

{

showTv = (TextView) findViewById(R.id.search_jing_tv); 

lvJing = (ListView) findViewById(R.id.search_lv_jing); 

initHeadView();

myAdapter = new MyAdapter();

lvJing.setAdapter(myAdapter); 

searchlv = (ListView) findViewById(R.id.search_listview);//搜索列表內(nèi)容

searchlv.setOnItemClickListener(new OnItemClickListener()

{


@Override

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

{

startActivity(new Intent(SearchActivity.this,DetileActivity.class));

}

});

searchAdapter = new SearchAdapter(); 

searchlv.setAdapter(searchAdapter);

ImageView exit = (ImageView) findViewById(R.id.search_exit);

titleTv = (TextView) findViewById(R.id.search_titleTv);

titleEdit = (EditText) findViewById(R.id.search_edit); 

titleEdit.addTextChangedListener(new TextWatcher()

{

@SuppressLint("DefaultLocale")

@Override

public void onTextChanged(CharSequence s, int start, int before, int count)

{   

mSearchList.clear();

String input = s.toString().toLowerCase(); 

if(!TextUtils.isEmpty(input))

{

for(int i=0;i<mAllcityList.size();i++)

{

Allcity allcity = mAllcityList.get(i);

String name = allcity.getName();

String pyCity = allcity.getPinyin(); 

if(name.startsWith(input)||input.startsWith(pyCity))

{

mSearchList.add(name);

searchAdapter.notifyDataSetChanged();

}

}

}

searchAdapter.notifyDataSetChanged();

}

@Override

public void beforeTextChanged(CharSequence s, int start, int count, int after)

{

}

@Override

public void afterTextChanged(Editable s)

{

}

});

cancle = (TextView) findViewById(R.id.search_cancle);

exit.setOnClickListener(this);  

titleTv.setOnClickListener(this);

cancle.setOnClickListener(this);

}

@SuppressLint("InflateParams")

private void initHeadView()

{

View headview=getLayoutInflater().inflate(R.layout.search_headview, null);

GridView4ScrollView gridHot = (GridView4ScrollView) headview.findViewById(R.id.search_grid02);

hotAdapter = new GridHotAdapter();

gridHot.setAdapter(hotAdapter); 

lvJing.addHeaderView(headview); 

 

}

class SearchAdapter extends BaseAdapter

{


@Override

public int getCount()

{

return mSearchList.size();

}


@Override

public Object getItem(int position)

{

return null;

}


@Override

public long getItemId(int position)

{

return 0;

}


@SuppressLint({ "ViewHolder", "InflateParams" })

@Override

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

{

View searchlayout=getLayoutInflater().inflate(R.layout.search_firstletter_linear, null);

TextView firstletter = (TextView) searchlayout.findViewById(R.id.firstletter_tv);

firstletter.setVisibility(View.GONE);

TextView infro = (TextView) searchlayout.findViewById(R.id.letter_infro);

infro.setText(mSearchList.get(position));

return searchlayout;

}

}

class GridHotAdapter extends BaseAdapter

{

@Override

public int getCount()

{

return mHotcityList.size();

}


@Override

public Object getItem(int position)

{

return null;

}


@Override

public long getItemId(int position)

{

return 0;

}


@SuppressLint({ "ViewHolder", "InflateParams" })

@Override

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

{

View gridLayout=getLayoutInflater().inflate(R.layout.headview5, null);

TextView tv = (TextView)gridLayout.findViewById(R.id.h6_tv);

tv.setTextSize(12);

Hotcity hotcity = mHotcityList.get(position);

tv.setText(hotcity.getName());

return gridLayout;

}

}


class MyAdapter extends BaseAdapter

{



@Override

public int getCount()

{

return mAllcityList.size();

}


@Override

public Object getItem(int position)

{

return null;

}


@Override

public long getItemId(int position)

{

return 0;

}


@SuppressLint({ "ViewHolder", "InflateParams" })

@Override

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

{

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

TextView firstletter = (TextView) layout.findViewById(R.id.firstletter_tv);

TextView infro = (TextView) layout.findViewById(R.id.letter_infro);

infro.setText(mAllcityList.get(position).getName());

if(mAllcityList.size()>0)

{

Allcity allcity = mAllcityList.get(position);

String first  = getLetter(allcity); 

if(position==0)

{

firstletter.setVisibility(View.VISIBLE);

firstletter.setText(first);

 

}else

{

Allcity allcity2 = mAllcityList.get(position-1);

String next = getLetter(allcity2);

if(first.equals(next))

{

firstletter.setVisibility(View.GONE);

}else

{

firstletter.setVisibility(View.VISIBLE);

firstletter.setText(first); 

}

}

}

return layout;

}

}

private void initLetterView()

{

letterView = (LetterView) findViewById(R.id.search_letterView);  

rn = new Runnable() { 

public void run() {

showTv.setVisibility(View.INVISIBLE);

}

};

letterView.setOnLetterTouchListener(new onLetterTouchListener()

{

@Override

public void onLetterTouchUp()

{

showTv.postDelayed(rn, 1000);

}

@Override

public void onLetterTouchDown(String letter)

{

showTv.removeCallbacks(rn);

showTv.setVisibility(View.VISIBLE);

showTv.setText(letter); 

if(letter.equals("熱門")||letter.equals("歷史")||letter.equals("推薦"))

{

lvJing.setSelection(0); 

}else

{

for(int i=0;i<mAllcityList.size();i++)

{

Allcity allcity = mAllcityList.get(i); 

String first = getLetter(allcity);

if(first.equals(letter))

{

lvJing.setSelection(i+lvJing.getHeaderViewsCount()); 

break;

}

}

}

}

});

}




private void initTabHost()

{

mTabHost = (TabHost) findViewById(android.R.id.tabhost);

mTabHost.setup();

mTabHost.addTab(mTabHost.newTabSpec("jn").setContent(android.R.id.tabcontent).setIndicator(getInd("境內(nèi)")));

}


@SuppressLint("InflateParams")

private View getInd(String str)

{

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

TextView tabTV = (TextView) view.findViewById(R.id.searchtab_tv);

tabTV.setText(str); 

return view;

}




@Override

public void onClick(View v)

{

switch (v.getId())

{

case R.id.search_exit:

SearchActivity.this.finish();

break;

case R.id.search_titleTv:

titleTv.setVisibility(View.GONE);

titleEdit.setVisibility(View.VISIBLE);

searchlv.setVisibility(View.VISIBLE); 

mTabHost.setVisibility(View.GONE);

cancle.setVisibility(View.VISIBLE); 

break;

case R.id.search_cancle:

titleTv.setVisibility(View.VISIBLE);

titleEdit.setVisibility(View.GONE);

cancle.setVisibility(View.GONE);

searchlv.setVisibility(View.GONE); 

mTabHost.setVisibility(View.VISIBLE);

break;

default:

break;

}

}

}



public class PhoneActivity extends Activity implements OnClickListener

{

@Override

protected void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_phone);

findControl();

}


private void findControl()

{

LinearLayout missPhone = (LinearLayout) findViewById(R.id.phone_miss);

LinearLayout dialPhone = (LinearLayout) findViewById(R.id.phone_dial);

dialPhone.setOnClickListener(this);

missPhone.setOnClickListener(this);

}


@Override

public void onClick(View v)

{

switch (v.getId())

{

case R.id.phone_miss:

PhoneActivity.this.finish();

break;

case R.id.phone_dial:

Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:4007-999-999")); 

startActivity(intent); 

PhoneActivity.this.finish();

break;

default:

break;

}

}


@Override

public void finish()

{

super.finish();

overridePendingTransition(0, R.anim.tween_slide_out);

}

}


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI