Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen Chen committed Oct 28, 2016
2 parents 0e1938f + 30b0798 commit 1af307e
Show file tree
Hide file tree
Showing 16 changed files with 97 additions and 45 deletions.
Binary file added XianBicycle3.1.apk
Binary file not shown.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "org.weyoung.xianbicycle"
minSdkVersion 16
targetSdkVersion 23
versionCode 4
versionName "3.0"
versionCode 5
versionName "3.1"
signingConfig signingConfigs.debug
}
buildTypes {
Expand Down Expand Up @@ -57,6 +57,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.0'
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'io.reactivex:rxjava:1.1.0'
compile 'io.reactivex:rxandroid:1.0.1'
Expand Down
Binary file added app/libs/mid-mid-sdk-2.3.jar
Binary file not shown.
Binary file removed app/libs/mid-sdk-2.10.jar
Binary file not shown.
Binary file added app/libs/mta-android-stat-sdk-2.1.0_20160111.jar
Binary file not shown.
Binary file removed app/libs/mta-sdk-2.0.3.jar
Binary file not shown.
16 changes: 11 additions & 5 deletions app/src/main/assets/log
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,31 @@

<p>该应用基于 <a href="http://xian-pub-bicycle.herokuapp.com/">公共自行车查询</a> 制作, 支持根据地点查询自行车租用情况, 在此感谢网站后台服务作者</p>

<b>3.0更新日志</b>
<b>3.1更新日志 (20160321)</b>

<p>1. 修复由于坐标系转换导致无法根据位置搜索的问题</p>
<p>2. 根据位置搜索的结果会标注大致距离</p>
<p>3. 修复已知问题,提升稳定性</p>

<b>3.0更新日志 (20160223)</b>

<p>1. 升级程序内核(网络,寻车导航)</p>
<p>2. 优化查询结果,可租可换更清晰</p>
<p>2. 优化查询结果,可租可还更清晰</p>
<p>3. 全面支持Android 6.0设备</p>
<p>4. 修复已知问题</p>

<b>2.1更新日志</b>
<b>2.1更新日志 (20150525)</b>

<p>1. 优化安装包体积</p>
<p>2. 修复已知崩溃</p>

<b>2.0更新日志</b>
<b>2.0更新日志 (20150522)</b>

<p>1. 加入收藏功能</p>
<p>2. 加入导航功能</p>
<p>3. 增强稳定性</p>

<b>1.0</b>
<b>1.0 (20150504)</b>

<p>首发</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class BicycleData {
private String siteid;
@Expose
private String sitename;
@Expose
private Double distance;

/**
*
Expand Down Expand Up @@ -144,4 +146,11 @@ public void setSitename(String sitename) {
this.sitename = sitename;
}

public Double getDistance() {
return distance;
}

public void setDistance(Double distance) {
this.distance = distance;
}
}
14 changes: 7 additions & 7 deletions app/src/main/java/org/weyoung/xianbicycle/data/Search.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

public class Search {
String term;
String lat;
String lng;
Double lat;
Double lng;
List<String> ids;

public Search(String s) {
term = s;
}

public Search(String lat, String lng) {
public Search(Double lat, Double lng) {
this.lat = lat;
this.lng = lng;
}
Expand All @@ -31,19 +31,19 @@ public void setTerm(String term) {
this.term = term;
}

public String getLat() {
public Double getLat() {
return lat;
}

public void setLat(String lat) {
public void setLat(Double lat) {
this.lat = lat;
}

public String getLng() {
public Double getLng() {
return lng;
}

public void setLng(String lng) {
public void setLng(Double lng) {
this.lng = lng;
}
}
30 changes: 19 additions & 11 deletions app/src/main/java/org/weyoung/xianbicycle/ui/BookmarkFragment.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
package org.weyoung.xianbicycle.ui;

import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import com.tencent.stat.StatService;

import org.weyoung.xianbicycle.R;
import org.weyoung.xianbicycle.data.BicycleData;
import org.weyoung.xianbicycle.data.Place;
import org.weyoung.xianbicycle.net.Loader;
import org.weyoung.xianbicycle.data.Search;
import org.weyoung.xianbicycle.net.Loader;
import org.weyoung.xianbicycle.utils.BookmarkUtil;
import org.weyoung.xianbicycle.utils.NavigationUtil;

Expand Down Expand Up @@ -61,7 +59,7 @@ public void onHiddenChanged(boolean hidden) {
void onResultItemClick(int index) {
BicycleData bicycleData = dataAdapter.getItem(index);
if (NavigationUtil.getLastKnown() == null) {
Toast.makeText(getActivity(), R.string.get_ur_location, Toast.LENGTH_SHORT).show();
showMessage(R.string.get_ur_location);
return;
}
NavigationUtil.launchNavigator(getActivity(),
Expand All @@ -86,8 +84,7 @@ private void refreshBookmark() {
try {
bookmark = BookmarkUtil.getAll(getActivity());
} catch (Exception e) {
StatService.reportError(getActivity(), "refreshBookmark " + e.getMessage());
Toast.makeText(getActivity(), R.string.error, Toast.LENGTH_SHORT).show();
showMessage(R.string.error);
return;
}
summaryView.setText(String.format(Locale.US, getResources().getString(R.string.bookmark_number), bookmark.size()));
Expand All @@ -102,22 +99,21 @@ public void onLoaderStarted() {
@Override
public void onLoaderFinished(List<BicycleData> data) {
if (data.size() == 0) {
Toast.makeText(getActivity(), R.string.no_result, Toast.LENGTH_SHORT).show();
showMessage(R.string.no_result);
} else {
try {
dataAdapter = new DataAdapter(getActivity(), data, BookmarkUtil.getAll(getActivity()));
resultView.setAdapter(dataAdapter);
} catch (Exception e) {
StatService.reportError(getActivity(), "refreshBookmark onLoaderFinished " + e.getMessage());
Toast.makeText(getActivity(), R.string.error, Toast.LENGTH_SHORT).show();
showMessage(R.string.error);
}
}
hideProgress();
}

@Override
public void onLoaderFailed() {
Toast.makeText(getActivity(), R.string.error, Toast.LENGTH_SHORT).show();
showMessage(R.string.error);
hideProgress();
}
}).load(new Search(bookmark));
Expand All @@ -127,4 +123,16 @@ public void onLoaderFailed() {
}
}

private void showMessage(int messageId) {
if (isAdded()) {
final Snackbar snackbar = Snackbar.make(getView(), getString(messageId), Snackbar.LENGTH_LONG);
snackbar.setAction(getString(R.string.hide), new View.OnClickListener() {
@Override
public void onClick(View v) {
snackbar.dismiss();
}
}).show();
}
}

}
8 changes: 8 additions & 0 deletions app/src/main/java/org/weyoung/xianbicycle/ui/ItemHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class ItemHolder {
TextView location;
@Bind(R.id.bookmark)
ImageView bookmark;
@Bind(R.id.distance)
TextView distance;

public ItemHolder(View view) {
context = view.getContext();
Expand All @@ -36,6 +38,12 @@ public void populate(final BicycleData data, List<String> bookmarkList) {
name.setText(data.getSitename());
status.setText(String.format(Locale.US, context.getString(R.string.result), getAvailableBike(data.getEmptynum(), data.getLocknum()), data.getEmptynum()));
location.setText(data.getLocation());
if (data.getDistance() != null) {
distance.setVisibility(View.VISIBLE);
distance.setText(String.format(Locale.US, "%dm", data.getDistance().intValue()));
} else {
distance.setVisibility(View.INVISIBLE);
}
boolean selected = bookmarkList.contains(data.getSiteid());
setBookmark(selected);
bookmark.setSelected(selected);
Expand Down
32 changes: 21 additions & 11 deletions app/src/main/java/org/weyoung/xianbicycle/ui/SearchFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.KeyEvent;
Expand All @@ -14,13 +15,11 @@
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.tencent.stat.StatService;

import org.weyoung.xianbicycle.R;
import org.weyoung.xianbicycle.data.BicycleData;
Expand Down Expand Up @@ -98,25 +97,24 @@ public void onLoaderStarted() {
@Override
public void onLoaderFinished(List<BicycleData> data) {
if (data.size() == 0) {
Toast.makeText(getActivity(), R.string.no_result, Toast.LENGTH_SHORT).show();
showMessage(R.string.no_result);
} else {
try {
dataAdapter = new DataAdapter(getActivity(), data, BookmarkUtil.getAll(getActivity()));
result.setAdapter(dataAdapter);
if (CoachUtil.isFirstLaunch(getContext())) {
Toast.makeText(getContext(), R.string.tips, Toast.LENGTH_LONG).show();
showMessage(R.string.tips);
}
} catch (Exception e) {
StatService.reportError(getActivity(), "query" + e.getMessage());
Toast.makeText(getActivity(), R.string.error, Toast.LENGTH_SHORT).show();
showMessage(R.string.error);
}
}
hideProgress();
}

@Override
public void onLoaderFailed() {
Toast.makeText(getActivity(), R.string.error, Toast.LENGTH_SHORT).show();
showMessage(R.string.error);
hideProgress();
}
}).load(search);
Expand All @@ -126,7 +124,7 @@ public void onLoaderFailed() {
void onResultItemClick(int index) {
BicycleData bicycleData = dataAdapter.getItem(index);
if (NavigationUtil.getLastKnown() == null) {
Toast.makeText(getActivity(), R.string.get_ur_location, Toast.LENGTH_SHORT).show();
showMessage(R.string.get_ur_location);
locationClient.start();
return;
}
Expand Down Expand Up @@ -155,7 +153,7 @@ private void hideProgress() {
private void initLocation() {
option = new LocationClientOption();
option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
option.setCoorType("bd09ll");
option.setCoorType("gcj02");
option.setScanSpan(5000);
option.setIsNeedAddress(true);
option.setNeedDeviceDirect(true);
Expand All @@ -181,7 +179,7 @@ public void onReceiveLocation(BDLocation location) {
}

if (isLocationSearch) {
query(new Search(String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())));
query(new Search(location.getLatitude(), location.getLongitude()));
isLocationSearch = false;
}
}
Expand All @@ -196,8 +194,20 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
dataAdapter.setBookmarkList(BookmarkUtil.getAll(sharedPreferences));
dataAdapter.notifyDataSetChanged();
} catch (Exception e) {
StatService.reportError(getActivity(), "onSharedPreferenceChanged " + e.getMessage());
showMessage(R.string.error);
}
}
}

private void showMessage(int messageId) {
if (isAdded()) {
final Snackbar snackbar = Snackbar.make(getView(), getString(messageId), Snackbar.LENGTH_LONG);
snackbar.setAction(getString(R.string.hide), new View.OnClickListener() {
@Override
public void onClick(View v) {
snackbar.dismiss();
}
}).show();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void launchNavigator(final Activity activity, Place end) {
return;
}
final BNRoutePlanNode startPoint = new BNRoutePlanNode(lastKnown.getLon(), lastKnown.getLat(),
lastKnown.getName(), null, BNRoutePlanNode.CoordinateType.BD09LL);
lastKnown.getName(), null, BNRoutePlanNode.CoordinateType.GCJ02);
BNRoutePlanNode endPoint = new BNRoutePlanNode(end.getLon(), end.getLat(),
end.getName(), null, BNRoutePlanNode.CoordinateType.BD09LL);
List<BNRoutePlanNode> list = new ArrayList<>();
Expand Down
24 changes: 16 additions & 8 deletions app/src/main/res/layout/item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/item_padding"
android:minHeight="@dimen/item_height">
android:minHeight="@dimen/item_height"
android:padding="@dimen/item_padding">

<TextView
android:id="@+id/name"
Expand All @@ -15,33 +15,41 @@

<TextView
android:id="@+id/status"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/bookmark"
android:layout_toLeftOf="@+id/distance"
android:layout_toRightOf="@+id/name"
android:textStyle="bold"
tools:text="(99/100)"/>

<TextView
android:id="@+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/bookmark"
android:textColor="@color/theme_accent"
tools:text="200m"/>

<TextView
android:id="@+id/location"
android:gravity="bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/bookmark"
android:layout_toLeftOf="@+id/bookmark"
android:gravity="bottom"
tools:text="Test Location"/>

<ImageView
android:id="@+id/bookmark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_bookmark"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:paddingBottom="@dimen/bookmark_padding_vertical"
android:paddingLeft="@dimen/bookmark_padding_left"
android:paddingRight="@dimen/bookmark_padding_right"
android:paddingTop="@dimen/bookmark_padding_vertical"
android:paddingBottom="@dimen/bookmark_padding_vertical"
android:layout_alignParentRight="true"/>
android:src="@drawable/ic_action_bookmark"/>

</RelativeLayout>
Loading

0 comments on commit 1af307e

Please sign in to comment.