查询功能的完善
This commit is contained in:
parent
ab72f6a242
commit
a28010ca58
|
@ -10,6 +10,7 @@ import android.graphics.Color;
|
|||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -44,6 +45,7 @@ public class ChooseLine extends AppCompatActivity {
|
|||
StationAdapter stationAdapter;
|
||||
List<Zhandian_item.SubwayLinesDTO> zhandianItems = new ArrayList<>();
|
||||
List<String> staion = new ArrayList<>();
|
||||
List<String> stationNew = new ArrayList<>();
|
||||
int selectedLineIndex = 0;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -88,6 +90,7 @@ public class ChooseLine extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
// Log.i("站点",s.toString());
|
||||
filterStationList(s.toString());
|
||||
}
|
||||
|
||||
|
@ -134,6 +137,7 @@ public class ChooseLine extends AppCompatActivity {
|
|||
List<String> stations = zhandianItems.get(0).stations;
|
||||
stationAdapter.notifyDataSetChanged();
|
||||
staion.addAll(stations);
|
||||
stationNew.addAll(stations);
|
||||
myAdapter.notifyDataSetChanged();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -148,6 +152,11 @@ public class ChooseLine extends AppCompatActivity {
|
|||
}
|
||||
private void filterStationList(String query) {
|
||||
// 如果查询字符串为空,则显示所有站点
|
||||
for (String stationName : stationNew) {
|
||||
if (stationName.toLowerCase().contains(query.toLowerCase())) {
|
||||
staion.add(stationName);
|
||||
}
|
||||
}
|
||||
if (query.isEmpty()) {
|
||||
stationAdapter.updateStationList(new ArrayList<>(staion));
|
||||
} else {
|
||||
|
@ -202,6 +211,7 @@ public class ChooseLine extends AppCompatActivity {
|
|||
List<String> stations = zhandianItems.get(position).stations;
|
||||
staion.clear();
|
||||
staion.addAll(stations);
|
||||
stationNew.addAll(stations);
|
||||
stationAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -38,6 +38,7 @@ public class ChufaTable extends AppCompatActivity {
|
|||
RecyclerView recyclerView;
|
||||
MyAdapter myAdapter;
|
||||
List<LineSearch_Item.DepartureDTO> departureDTOS = new ArrayList<>();
|
||||
List<LineSearch_Item.DepartureDTO> departureDTOSNew = new ArrayList<>();
|
||||
EditText searchEditText;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -111,6 +112,7 @@ public class ChufaTable extends AppCompatActivity {
|
|||
Gson gson = new Gson();
|
||||
LineSearch_Item lineSearchItem = gson.fromJson(result,LineSearch_Item.class);
|
||||
departureDTOS.addAll(lineSearchItem.departure);
|
||||
departureDTOSNew.addAll(lineSearchItem.departure);
|
||||
myAdapter.notifyDataSetChanged();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -125,6 +127,9 @@ public class ChufaTable extends AppCompatActivity {
|
|||
}
|
||||
private void filterStationList(String query) {
|
||||
// 如果查询字符串为空,则显示所有站点
|
||||
for (LineSearch_Item.DepartureDTO departureDTO : departureDTOSNew) {
|
||||
departureDTOS.add(departureDTO);
|
||||
}
|
||||
if (query.isEmpty()) {
|
||||
myAdapter.updateStationList(new ArrayList<>(departureDTOS));
|
||||
} else
|
||||
|
|
|
@ -38,6 +38,7 @@ public class DaonaTable extends AppCompatActivity {
|
|||
RecyclerView recyclerView;
|
||||
MyAdapter myAdapter;
|
||||
List<LineSearch_Item.DestinationDTO> destinationDTOS = new ArrayList<>();
|
||||
List<LineSearch_Item.DestinationDTO> destinationDTOSNew = new ArrayList<>();
|
||||
EditText searchEditText;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -112,6 +113,7 @@ public class DaonaTable extends AppCompatActivity {
|
|||
Gson gson = new Gson();
|
||||
LineSearch_Item lineSearchItem = gson.fromJson(result,LineSearch_Item.class);
|
||||
destinationDTOS.addAll(lineSearchItem.destination);
|
||||
destinationDTOSNew.addAll(lineSearchItem.destination);
|
||||
myAdapter.notifyDataSetChanged();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -126,6 +128,9 @@ public class DaonaTable extends AppCompatActivity {
|
|||
}
|
||||
private void filterStationList(String query) {
|
||||
// 如果查询字符串为空,则显示所有站点
|
||||
for (LineSearch_Item.DestinationDTO destinationDTO : destinationDTOSNew) {
|
||||
destinationDTOS.add(destinationDTO);
|
||||
}
|
||||
if (query.isEmpty()) {
|
||||
myAdapter.updateStationList(new ArrayList<>(destinationDTOS));
|
||||
} else
|
||||
|
|
|
@ -8,31 +8,40 @@ import android.view.View;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class Havemessage extends AppCompatActivity {
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
public class Havemessage extends AppCompatActivity {
|
||||
boolean haveMessage;
|
||||
TextView cleanMessage;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_havemessage);
|
||||
|
||||
cleanMessage = findViewById(R.id.textView18);
|
||||
ImageView num1 = findViewById(R.id.imageView16);
|
||||
ImageView num2 = findViewById(R.id.imageView17);
|
||||
//todo 返回首页
|
||||
ImageView back = findViewById(R.id.imageView13);
|
||||
back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(Havemessage.this, Shouye.class);
|
||||
intent.putExtra("id", 3);
|
||||
intent.putExtra("isLogin", true);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
//todo 将消息全部标为已读
|
||||
TextView cleanMessage = findViewById(R.id.textView18);
|
||||
ImageView num1 = findViewById(R.id.imageView16);
|
||||
ImageView num2 = findViewById(R.id.imageView17);
|
||||
|
||||
cleanMessage.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
cleanMessage.setVisibility(View.INVISIBLE);
|
||||
num1.setVisibility(View.INVISIBLE);
|
||||
num2.setVisibility(View.INVISIBLE);
|
||||
haveMessage=true;
|
||||
// EventBus.getDefault().post(haveMessage);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -46,4 +55,5 @@ public class Havemessage extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -21,19 +21,22 @@ import com.youth.banner.adapter.BannerImageAdapter;
|
|||
import com.youth.banner.holder.BannerImageHolder;
|
||||
import com.youth.banner.indicator.CircleIndicator;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ShouyeFragment extends Fragment {
|
||||
|
||||
ImageView message;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
ImmersionBar.with(this).init();
|
||||
View view = inflater.inflate(R.layout.fragment_shouye, container, false);
|
||||
ImageView message = view.findViewById(R.id.imageView11);
|
||||
// EventBus.getDefault().register(getContext());
|
||||
message = view.findViewById(R.id.imageView11);
|
||||
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("https://alifei03.cfp.cn/creative/vcg/800/new/VCG41N1349337241.jpg");
|
||||
|
@ -58,14 +61,16 @@ public class ShouyeFragment extends Fragment {
|
|||
// banner.setBannerGalleryEffect(10,10,3) ;
|
||||
banner.setScrollTime(800);
|
||||
|
||||
//信息
|
||||
message.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getContext(), Havemessage.class);
|
||||
startActivity(intent);
|
||||
message.setSelected(true);
|
||||
// message.setSelected(true);
|
||||
}
|
||||
});
|
||||
boolean haveMessage ;
|
||||
//todo 在线购票
|
||||
ConstraintLayout onlineBuy = view.findViewById(R.id.constraintLayout5);
|
||||
onlineBuy.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -123,4 +128,10 @@ public class ShouyeFragment extends Fragment {
|
|||
|
||||
return view;
|
||||
}
|
||||
// public void onEvent(boolean haveMessage){
|
||||
//
|
||||
// this.message.setSelected(haveMessage);
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
|
@ -34,6 +34,7 @@ public class Station extends AppCompatActivity {
|
|||
RecyclerView recyclerView ;
|
||||
MyAdapter myAdapter ;
|
||||
List<String> stationItemList = new ArrayList<>();
|
||||
List<String> stationItemListNew = new ArrayList<>();
|
||||
EditText searchEditText;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -106,6 +107,7 @@ public class Station extends AppCompatActivity {
|
|||
Gson gson = new Gson();
|
||||
Station_item station_item = gson.fromJson(result,Station_item.class);
|
||||
stationItemList.addAll(station_item.stations);
|
||||
stationItemListNew.addAll(station_item.stations);
|
||||
myAdapter.notifyDataSetChanged();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -121,6 +123,10 @@ public class Station extends AppCompatActivity {
|
|||
|
||||
private void filterStationList(String query) {
|
||||
// 如果查询字符串为空,则显示所有站点
|
||||
stationItemList.clear();
|
||||
for (String stationName : stationItemListNew) {
|
||||
stationItemList.add(stationName);
|
||||
}
|
||||
if (query.isEmpty()) {
|
||||
myAdapter.updateStationList(new ArrayList<>(stationItemList));
|
||||
} else {
|
||||
|
|
|
@ -18,8 +18,9 @@ public class SystemInformation extends AppCompatActivity {
|
|||
back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(SystemInformation.this, Havemessage.class);
|
||||
startActivity(intent);
|
||||
// Intent intent = new Intent(SystemInformation.this, Havemessage.class);
|
||||
// startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue