button choose from map redirects to mapActivity
This commit is contained in:
parent
1acac4edc4
commit
d62c451adb
@ -16,11 +16,13 @@ import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
import com.uam.wmi.findmytutor.utils.RightButtonPreference;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@ -53,17 +55,18 @@ public class SharingFragment extends PreferenceFragment {
|
||||
Preference locationMode = findPreference("key_location_level");
|
||||
Preference statusList = findPreference("key_status_value");
|
||||
Preference manualLocationList = findPreference("key_manual_location_value");
|
||||
Preference manualLocationButton = findPreference("manual_location_button");
|
||||
|
||||
RightButtonPreference manualLocationButton = (RightButtonPreference) findPreference("manual_location_button");
|
||||
PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("category_sharing");
|
||||
String temp = PrefUtils.getLocationLevel(getApplicationContext());
|
||||
if(!temp.equals("manual")){
|
||||
preferenceCategory.removePreference(manualLocationList);
|
||||
preferenceCategory.removePreference(manualLocationButton);
|
||||
}
|
||||
manualLocationButton.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
manualLocationButton.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Toast.makeText(getApplicationContext(), "dupa", Toast.LENGTH_SHORT).show();
|
||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||
//ToDO wywołanie wybierania lokalizacji z mapy
|
||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||
fragmentTransaction.hide(SharingFragment.this);
|
||||
fragmentTransaction.commit();
|
||||
|
@ -0,0 +1,45 @@
|
||||
package com.uam.wmi.findmytutor.utils;
|
||||
import android.content.Context;
|
||||
import android.preference.Preference;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
|
||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
||||
|
||||
public class RightButtonPreference extends Preference {
|
||||
|
||||
public RightButtonPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setWidgetLayoutResource(R.layout.preference_button_widget);
|
||||
}
|
||||
@Override
|
||||
protected View onCreateView(ViewGroup parent) {
|
||||
View view = super.onCreateView(parent);
|
||||
// LayoutInflater li = (LayoutInflater)getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
|
||||
// View temp =li.inflate( R.layout.preference_button_widget, parent, false);
|
||||
return view;
|
||||
}
|
||||
@Override
|
||||
protected void onBindView(View view)
|
||||
{
|
||||
super.onBindView(view);
|
||||
Button button = (Button)view.findViewById(R.id.button_choose_from_map);
|
||||
if(button != null)
|
||||
{
|
||||
button.setText("dupa");
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Toast.makeText(getApplicationContext(), "dupa4", Toast.LENGTH_SHORT).show();
|
||||
callChangeListener(null);
|
||||
notifyChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package com.uam.wmi.findmytutor.utils;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import android.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
|
||||
public class rightButtonPreference extends Preference {
|
||||
public rightButtonPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
// setLayoutResource(R.layout.preference_button_widget);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected View onCreateView(ViewGroup parent) {
|
||||
View view = super.onCreateView(parent);
|
||||
LayoutInflater li = (LayoutInflater)getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
|
||||
return li.inflate( R.layout.preference_button_widget, parent, false);
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||
super.onBindViewHolder(holder);
|
||||
holder.itemView.setClickable(false); // disable parent click
|
||||
View button = holder.findViewById(R.id.theme_dark);
|
||||
button.setClickable(true); // enable custom view click
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
}
|
||||
});
|
||||
}*/
|
||||
}
|
@ -30,7 +30,7 @@
|
||||
android:entryValues="@array/manual_location_values"
|
||||
android:summary="%s"
|
||||
android:title="@string/title_list_manual_location" />
|
||||
<com.uam.wmi.findmytutor.utils.rightButtonPreference
|
||||
<com.uam.wmi.findmytutor.utils.RightButtonPreference
|
||||
android:key="manual_location_button"
|
||||
/>
|
||||
</PreferenceCategory>
|
||||
|
@ -5,7 +5,7 @@
|
||||
android:gravity="right"
|
||||
>
|
||||
<Button xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/button"
|
||||
android:id="@+id/button_choose_from_map"
|
||||
android:text="@string/preference_manual_location_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
Loading…
Reference in New Issue
Block a user