Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ReportFragment.java « editor « maps « mapswithme « com « src « android - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 44d2bf8f5011f959474c3ff7e5aa265390d3515c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.mapswithme.maps.editor;

import android.os.Bundle;
import android.support.annotation.IntRange;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmToolbarFragment;
import com.mapswithme.util.UiUtils;

public class ReportFragment extends BaseMwmToolbarFragment implements View.OnClickListener
{
  private View mSimpleProblems;
  private View mAdvancedProblem;
  private View mSave;
  private EditText mProblemInput;

  private boolean mAdvancedMode;
  @IntRange(from = 0, to = 3)
  private int mSelectedProblem;

  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
  {
    return inflater.inflate(R.layout.fragment_report, container, false);
  }

  @Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
  {
    super.onViewCreated(view, savedInstanceState);
    mToolbarController.setTitle(R.string.editor_report_problem_title);

    mSave = mToolbarController.findViewById(R.id.save);
    mSave.setOnClickListener(this);
    mSimpleProblems = view.findViewById(R.id.ll__problems);
    mSimpleProblems.findViewById(R.id.problem_not_exist).setOnClickListener(this);
//    mSimpleProblems.findViewById(R.id.problem_closed_repair).setOnClickListener(this);
//    mSimpleProblems.findViewById(R.id.problem_duplicated_place).setOnClickListener(this);
    mSimpleProblems.findViewById(R.id.problem_other).setOnClickListener(this);
    mAdvancedProblem = view.findViewById(R.id.ll__other_problem);
    mProblemInput = (EditText) mAdvancedProblem.findViewById(R.id.input);
    refreshProblems();
  }

  private void refreshProblems()
  {
    UiUtils.showIf(mAdvancedMode, mAdvancedProblem, mSave);
    UiUtils.showIf(!mAdvancedMode, mSimpleProblems);
  }

  private void send(String text)
  {
    Editor.nativeCreateNote(text);
    mToolbarController.onUpClick();
  }

  private void sendNotExist()
  {
    Editor.nativePlaceDoesNotExist("");
    mToolbarController.onUpClick();
  }

  @Override
  public void onClick(View v)
  {
    switch (v.getId())
    {
    case R.id.problem_not_exist:
//    case R.id.problem_closed_repair:
//    case R.id.problem_duplicated_place:
      sendNotExist();
      break;

    case R.id.problem_other:
      mAdvancedMode = true;
      refreshProblems();
      break;

    case R.id.save:
      String text = mProblemInput.getText().toString().trim();
      if (TextUtils.isEmpty(text))
        return;

      send(text);
      break;
    }
  }
}