Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
17c5a349c8
3 changed files with 123 additions and 0 deletions
6
OsmAnd/res/layout/quick_action_widget.xml
Normal file
6
OsmAnd/res/layout/quick_action_widget.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</LinearLayout>
|
6
OsmAnd/res/layout/quick_action_widget_item.xml
Normal file
6
OsmAnd/res/layout/quick_action_widget_item.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</LinearLayout>
|
111
OsmAnd/src/net/osmand/plus/quickaction/QuickActionsWidget.java
Normal file
111
OsmAnd/src/net/osmand/plus/quickaction/QuickActionsWidget.java
Normal file
|
@ -0,0 +1,111 @@
|
|||
package net.osmand.plus.quickaction;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class QuickActionsWidget extends LinearLayout {
|
||||
|
||||
private List<QuickAction> actions;
|
||||
|
||||
private ImageButton next;
|
||||
private ImageButton prev;
|
||||
|
||||
private ViewPager viewPager;
|
||||
|
||||
public QuickActionsWidget(Context context) {
|
||||
super(context);
|
||||
setup();
|
||||
}
|
||||
|
||||
public QuickActionsWidget(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setup();
|
||||
}
|
||||
|
||||
public QuickActionsWidget(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
setup();
|
||||
}
|
||||
|
||||
public void setActions(List<QuickAction> actions){
|
||||
this.actions = actions;
|
||||
}
|
||||
|
||||
private void setup(){
|
||||
inflate(getContext(), R.layout.quick_action_widget, this);
|
||||
|
||||
// viewPager = (ViewPager) findViewById(R.id.viewPager);
|
||||
// viewPager.setAdapter(new ViewsPagerAdapter());
|
||||
//
|
||||
// next = (ImageButton) findViewById(R.id.btnNext);
|
||||
// prev = (ImageButton) findViewById(R.id.btnPrev);
|
||||
//
|
||||
// next.setOnClickListener(new OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
//
|
||||
// if (viewPager.getAdapter().getCount() > viewPager.getCurrentItem() + 1) {
|
||||
// viewPager.setCurrentItem(viewPager.getCurrentItem() + 1);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// prev.setOnClickListener(new OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
//
|
||||
// if (viewPager.getCurrentItem() - 1 >= 0) {
|
||||
// viewPager.setCurrentItem(viewPager.getCurrentItem() - 1);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
private View createPageView(ViewGroup container){
|
||||
//TODO setup it
|
||||
return getLayoutInflater().inflate(R.layout.quick_action_widget_item, container, false);
|
||||
}
|
||||
|
||||
private class ViewsPagerAdapter extends PagerAdapter {
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return (int) Math.ceil(actions.size() / 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object instantiateItem(ViewGroup container, int position) {
|
||||
|
||||
View view = createPageView(container);
|
||||
container.addView(view, 0);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyItem(ViewGroup collection, int position, Object view) {
|
||||
collection.removeView((View) view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return view == object;
|
||||
}
|
||||
}
|
||||
|
||||
private LayoutInflater getLayoutInflater(){
|
||||
return (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue