forked from organicmaps/organicmaps
[android] Fixed osm login crash.
This commit is contained in:
parent
8b5964ab8e
commit
a3aa2d7d31
4 changed files with 33 additions and 16 deletions
|
@ -1,5 +1,6 @@
|
|||
package com.mapswithme.maps.editor;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -11,8 +12,6 @@ import com.mapswithme.maps.base.BaseMwmDialogFragment;
|
|||
|
||||
public class AuthDialogFragment extends BaseMwmDialogFragment
|
||||
{
|
||||
private OsmAuthFragmentDelegate mOsmAuthDelegate;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
|
||||
|
@ -30,7 +29,15 @@ public class AuthDialogFragment extends BaseMwmDialogFragment
|
|||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mOsmAuthDelegate = new OsmAuthFragmentDelegate(this);
|
||||
mOsmAuthDelegate.onViewCreated(view, savedInstanceState);
|
||||
OsmAuthFragmentDelegate osmAuthDelegate = new OsmAuthFragmentDelegate(this)
|
||||
{
|
||||
@Override
|
||||
protected void loginOsm()
|
||||
{
|
||||
startActivity(new Intent(getContext(), OsmAuthActivity.class));
|
||||
dismiss();
|
||||
}
|
||||
};
|
||||
osmAuthDelegate.onViewCreated(view, savedInstanceState);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,14 +8,13 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmFragmentActivity;
|
||||
import com.mapswithme.maps.base.BaseMwmToolbarFragment;
|
||||
import com.mapswithme.maps.widget.ToolbarController;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
public class AuthFragment extends BaseMwmToolbarFragment
|
||||
{
|
||||
private OsmAuthFragmentDelegate mOsmAuthDelegate;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
|
||||
|
@ -28,8 +27,15 @@ public class AuthFragment extends BaseMwmToolbarFragment
|
|||
{
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mToolbarController.setTitle(R.string.thank_you);
|
||||
mOsmAuthDelegate = new OsmAuthFragmentDelegate(this);
|
||||
mOsmAuthDelegate.onViewCreated(view, savedInstanceState);
|
||||
OsmAuthFragmentDelegate osmAuthDelegate = new OsmAuthFragmentDelegate(this)
|
||||
{
|
||||
@Override
|
||||
protected void loginOsm()
|
||||
{
|
||||
((BaseMwmFragmentActivity) getActivity()).replaceFragment(OsmAuthFragment.class, null, null);
|
||||
}
|
||||
};
|
||||
osmAuthDelegate.onViewCreated(view, savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,6 +16,7 @@ import android.widget.TextView;
|
|||
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmFragmentActivity;
|
||||
import com.mapswithme.maps.base.BaseMwmToolbarFragment;
|
||||
import com.mapswithme.maps.widget.ToolbarController;
|
||||
import com.mapswithme.util.Constants;
|
||||
|
@ -64,7 +65,14 @@ public class OsmAuthFragment extends BaseMwmToolbarFragment implements View.OnCl
|
|||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mDelegate = new OsmAuthFragmentDelegate(this);
|
||||
mDelegate = new OsmAuthFragmentDelegate(this)
|
||||
{
|
||||
@Override
|
||||
protected void loginOsm()
|
||||
{
|
||||
((BaseMwmFragmentActivity) getActivity()).replaceFragment(OsmAuthFragment.class, null, null);
|
||||
}
|
||||
};
|
||||
mDelegate.onViewCreated(view, savedInstanceState);
|
||||
mToolbarController.setTitle(R.string.login);
|
||||
mEtLogin = (EditText) view.findViewById(R.id.osm_username);
|
||||
|
|
|
@ -15,7 +15,6 @@ import android.webkit.WebView;
|
|||
import android.webkit.WebViewClient;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmFragmentActivity;
|
||||
import com.mapswithme.maps.widget.InputWebView;
|
||||
import com.mapswithme.util.Constants;
|
||||
import com.mapswithme.util.Utils;
|
||||
|
@ -23,10 +22,12 @@ import com.mapswithme.util.concurrency.ThreadPool;
|
|||
import com.mapswithme.util.concurrency.UiThread;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
public class OsmAuthFragmentDelegate implements View.OnClickListener
|
||||
public abstract class OsmAuthFragmentDelegate implements View.OnClickListener
|
||||
{
|
||||
private final Fragment mFragment;
|
||||
|
||||
protected abstract void loginOsm();
|
||||
|
||||
public OsmAuthFragmentDelegate(Fragment fragment)
|
||||
{
|
||||
mFragment = fragment;
|
||||
|
@ -92,11 +93,6 @@ public class OsmAuthFragmentDelegate implements View.OnClickListener
|
|||
Statistics.params().add(Statistics.EventParam.IS_SUCCESS, true).add(Statistics.EventParam.TYPE, type.name));
|
||||
}
|
||||
|
||||
protected void loginOsm()
|
||||
{
|
||||
((BaseMwmFragmentActivity) mFragment.getActivity()).replaceFragment(OsmAuthFragment.class, null, null);
|
||||
}
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
protected void loginWebview(final OsmOAuth.AuthType type)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue