Search in sources :

Example 1 with StopZone

use of flying.grub.tamtime.data.map.StopZone in project TamTime by flyingrub.

the class OneStopActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.action_favorite:
            if (favoriteStops.isInFav(stop)) {
                favoriteStops.remove(stop);
                item.setIcon(R.drawable.ic_star_border_white_24dp);
            } else {
                favoriteStops.add(stop);
                item.setIcon(R.drawable.ic_star_white_24dp);
            }
            return true;
        case R.id.report:
            choiceReportDialog();
            return true;
        case R.id.report_warn:
            createAllReportDialog();
            return true;
        case R.id.action_add_line_on_home:
            ArrayList<CharSequence> lines = new ArrayList<>();
            for (Line l : stop.getLines()) {
                lines.add("Ligne " + l.getShortName());
            }
            CharSequence[] lineString = lines.toArray(new CharSequence[lines.size()]);
            MaterialDialog dialog = new MaterialDialog.Builder(OneStopActivity.this).title(R.string.line_choice).items(lineString).itemsCallback(new MaterialDialog.ListCallback() {

                @Override
                public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                    StopZone s = stop;
                    Line l = s.getLines().get(which);
                    favoriteStopLine.addLineStop(l, s);
                    dialog.dismiss();
                }
            }).build();
            dialog.show();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
Also used : Line(flying.grub.tamtime.data.map.Line) FavoriteStopLine(flying.grub.tamtime.data.persistence.FavoriteStopLine) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ArrayList(java.util.ArrayList) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) StopZone(flying.grub.tamtime.data.map.StopZone)

Example 2 with StopZone

use of flying.grub.tamtime.data.map.StopZone in project TamTime by flyingrub.

the class HomeAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holderParam, int position) {
    if (holderParam instanceof ViewHolderCustom) {
        return;
    }
    ViewHolder holder = (ViewHolder) holderParam;
    LineStop lineStop = favoriteStopLine.get(position - 1);
    StopZone s = lineStop.getStopZone();
    Line l = lineStop.getLine();
    holder.title.setText(s.getName() + " - Ligne " + l.getLineNum());
    holder.recyclerView.setHasFixedSize(true);
    RecyclerView.LayoutManager layoutManager = new org.solovyev.android.views.llm.LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
    holder.recyclerView.setLayoutManager(layoutManager);
    holder.recyclerView.setItemAnimator(new DefaultItemAnimator());
    AllDirectionStopLine adapter = new AllDirectionStopLine(s.getStops(l), context);
    final StopZone finalS = s;
    adapter.SetOnItemClickListener(new AllDirectionStopLine.OnItemClickListener() {

        @Override
        public void onItemClick(View view, int position) {
            Intent intent = new Intent(context, OneStopActivity.class);
            Bundle bundle = new Bundle();
            bundle.putInt("stop_zone_id", finalS.getID());
            intent.putExtras(bundle);
            context.startActivity(intent);
            context.overridePendingTransition(R.anim.slide_from_right, R.anim.fade_scale_out);
        }
    });
    holder.recyclerView.setAdapter(adapter);
}
Also used : LineStop(flying.grub.tamtime.data.persistence.LineStop) Bundle(android.os.Bundle) Intent(android.content.Intent) OneStopActivity(flying.grub.tamtime.activity.OneStopActivity) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) SearchView(flying.grub.tamtime.layout.SearchView) FavHomeView(flying.grub.tamtime.layout.FavHomeView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) Line(flying.grub.tamtime.data.map.Line) RecyclerView(android.support.v7.widget.RecyclerView) StopZone(flying.grub.tamtime.data.map.StopZone)

Example 3 with StopZone

use of flying.grub.tamtime.data.map.StopZone in project TamTime by flyingrub.

the class FavoriteStops method pushToPref.

public void pushToPref() {
    SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = defaultSharedPreferences.edit();
    ArrayList<String> fav = new ArrayList<>();
    for (StopZone s : favoriteStop) {
        fav.add("" + s.getID());
    }
    editor.putStringSet(TAG, new HashSet<>(fav));
    editor.commit();
}
Also used : SharedPreferences(android.content.SharedPreferences) ArrayList(java.util.ArrayList) StopZone(flying.grub.tamtime.data.map.StopZone)

Example 4 with StopZone

use of flying.grub.tamtime.data.map.StopZone in project TamTime by flyingrub.

the class ReportEvent method setReport.

public void setReport(JSONArray reportJson) {
    for (Report r : this.reportList) {
        r.removeFromStop();
    }
    this.reportList = new ArrayList<>();
    try {
        for (int i = 0; i < reportJson.length(); i++) {
            JSONObject reportObjectJson = reportJson.getJSONObject(i);
            String msg = reportObjectJson.optString("message");
            int confirm = reportObjectJson.getInt("confirm");
            int reportId = reportObjectJson.getInt("id");
            Calendar date = Calendar.getInstance();
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                date.setTime(sdf.parse(reportObjectJson.getString("date")));
            } catch (Exception e) {
                e.printStackTrace();
            }
            StopZone stop = Data.getData().getMap().getStopZoneById(reportObjectJson.getInt("stop"));
            if (stop != null) {
                Report report = new Report(stop, ReportType.reportFromId(reportObjectJson.getInt("type")), msg, date, confirm, reportId);
                this.reportList.add(report);
            }
        }
        EventBus.getDefault().post(new MessageUpdate(MessageUpdate.Type.REPORT_UPDATE));
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
Also used : JSONObject(org.json.JSONObject) Calendar(java.util.Calendar) JSONException(org.json.JSONException) MessageUpdate(flying.grub.tamtime.data.update.MessageUpdate) SimpleDateFormat(java.text.SimpleDateFormat) StopZone(flying.grub.tamtime.data.map.StopZone) JSONException(org.json.JSONException)

Example 5 with StopZone

use of flying.grub.tamtime.data.map.StopZone in project TamTime by flyingrub.

the class AllStopFragment method selectitem.

public void selectitem(int i) {
    StopZone s = currentDisplayedStop.get(i);
    Intent intent = new Intent(getActivity(), OneStopActivity.class);
    Bundle bundle = new Bundle();
    bundle.putInt("stop_zone_id", s.getID());
    intent.putExtras(bundle);
    startActivity(intent);
    getActivity().overridePendingTransition(R.anim.slide_from_right, R.anim.fade_scale_out);
}
Also used : Bundle(android.os.Bundle) Intent(android.content.Intent) StopZone(flying.grub.tamtime.data.map.StopZone)

Aggregations

StopZone (flying.grub.tamtime.data.map.StopZone)11 Intent (android.content.Intent)5 Bundle (android.os.Bundle)5 Line (flying.grub.tamtime.data.map.Line)5 RecyclerView (android.support.v7.widget.RecyclerView)4 View (android.view.View)4 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 ArrayList (java.util.ArrayList)3 SharedPreferences (android.content.SharedPreferences)2 TextView (android.widget.TextView)2 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)2 FavoriteStopLine (flying.grub.tamtime.data.persistence.FavoriteStopLine)2 FavHomeView (flying.grub.tamtime.layout.FavHomeView)2 SearchView (flying.grub.tamtime.layout.SearchView)2 PopupMenu (android.support.v7.widget.PopupMenu)1 MenuItem (android.view.MenuItem)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 OneStopActivity (flying.grub.tamtime.activity.OneStopActivity)1