Search in sources :

Example 1 with BackgroundPreviewView

use of im.actor.sdk.view.BackgroundPreviewView in project actor-platform by actorapp.

the class PickWallpaperFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ActorStyle style = ActorSDK.sharedActor().style;
    shp = getActivity().getSharedPreferences("wallpaper", Context.MODE_PRIVATE);
    ed = shp.edit();
    selectedWallpaper = getArguments().getInt("EXTRA_ID");
    if (selectedWallpaper == -1) {
        selectedWallpaper = BackgroundPreviewView.getBackgroundIdByUri(messenger().getSelectedWallpaper(), getContext(), shp.getInt("wallpaper", 0));
    }
    View res = inflater.inflate(R.layout.fragment_pick_wallpaper, container, false);
    res.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
    ((TextView) res.findViewById(R.id.cancel)).setTextColor(ActorSDK.sharedActor().style.getTextPrimaryColor());
    ((TextView) res.findViewById(R.id.ok)).setTextColor(ActorSDK.sharedActor().style.getTextPrimaryColor());
    res.findViewById(R.id.dividerTop).setBackgroundColor(ActorSDK.sharedActor().style.getDividerColor());
    res.findViewById(R.id.dividerBot).setBackgroundColor(ActorSDK.sharedActor().style.getDividerColor());
    res.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            getActivity().finish();
        }
    });
    res.findViewById(R.id.ok).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            messenger().changeSelectedWallpaper("local:".concat(getResources().getResourceEntryName(BackgroundPreviewView.getBackground(selectedWallpaper))));
            ed.putInt("wallpaper", selectedWallpaper);
            ed.commit();
            getActivity().finish();
        }
    });
    wallpaper = (ChatBackgroundView) res.findViewById(R.id.wallpaper);
    wallpaper.bind(selectedWallpaper);
    LinearLayout botContainer = (LinearLayout) res.findViewById(R.id.wallpaper_preview_container);
    LinearLayout wallpaperContainer = (LinearLayout) res.findViewById(R.id.background_container);
    botContainer.setBackgroundColor(style.getMainBackgroundColor());
    View.OnClickListener ocl = new View.OnClickListener() {

        @Override
        public void onClick(final View v) {
            selectedWallpaper = (int) v.getTag();
            wallpaper.bind(selectedWallpaper);
        }
    };
    int previewSize = 90;
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(Screen.dp(previewSize), Screen.dp(previewSize));
    for (int i = 0; i < BackgroundPreviewView.getSize(); i++) {
        FrameLayout frame = new FrameLayout(getActivity());
        BackgroundPreviewView bckgrnd = new BackgroundPreviewView(getActivity());
        bckgrnd.init(Screen.dp(previewSize), Screen.dp(previewSize));
        bckgrnd.bind(i);
        //bckgrnd.setPadding(Screen.dp(5), Screen.dp(10), Screen.dp(5), Screen.dp(20));
        frame.setTag(i);
        frame.setOnClickListener(ocl);
        frame.addView(bckgrnd);
        wallpaperContainer.addView(frame, params);
    }
    return res;
}
Also used : ActorStyle(im.actor.sdk.ActorStyle) FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) TextView(android.widget.TextView) ChatBackgroundView(im.actor.sdk.controllers.conversation.view.ChatBackgroundView) View(android.view.View) BackgroundPreviewView(im.actor.sdk.view.BackgroundPreviewView) LinearLayout(android.widget.LinearLayout) BackgroundPreviewView(im.actor.sdk.view.BackgroundPreviewView)

Example 2 with BackgroundPreviewView

use of im.actor.sdk.view.BackgroundPreviewView in project actor-platform by actorapp.

the class WallpapersAdapter method onCreateViewHolder.

@Override
public WallpaperHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    BackgroundPreviewView itemView = new BackgroundPreviewView(parent.getContext());
    itemView.init(wallpaperSize, wallpaperSize, Screen.dp(2));
    itemView.setLayoutParams(params);
    padding = Screen.dp(8);
    ImageView selected = new ImageView(parent.getContext());
    selected.setImageResource(R.drawable.ic_done_white_36dp);
    selected.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    int selectedPadding = Screen.dp(12);
    int selectedSize = Screen.dp(48);
    selected.setPadding(selectedPadding, selectedPadding, selectedPadding, selectedPadding);
    selected.setBackgroundResource(R.drawable.avatar_background);
    FrameLayout fl = new FrameLayout(parent.getContext());
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(wallpaperSize, wallpaperSize, Gravity.LEFT | Gravity.CENTER_VERTICAL);
    params.setMargins(0, 0, Screen.dp(8), 0);
    fl.addView(itemView, params);
    FrameLayout.LayoutParams params1 = new FrameLayout.LayoutParams(selectedSize, selectedSize, Gravity.LEFT | Gravity.CENTER_VERTICAL);
    params1.setMargins(Screen.dp(18.5f), 0, 0, 0);
    fl.addView(selected, params1);
    return new WallpaperHolder(fl, itemView, selected);
}
Also used : FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) BackgroundPreviewView(im.actor.sdk.view.BackgroundPreviewView)

Aggregations

FrameLayout (android.widget.FrameLayout)2 BackgroundPreviewView (im.actor.sdk.view.BackgroundPreviewView)2 View (android.view.View)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 ActorStyle (im.actor.sdk.ActorStyle)1 ChatBackgroundView (im.actor.sdk.controllers.conversation.view.ChatBackgroundView)1