Search in sources :

Example 1 with HomeActivity

use of com.sdsmdg.harjot.MusicDNA.activities.HomeActivity in project MusicDNA by harjot-oberai.

the class QueueRecyclerAdapter method onItemDismiss.

@Override
public void onItemDismiss(int position) {
    UnifiedTrack ut = queue.get(position);
    if (HomeActivity.originalQueue != null)
        HomeActivity.originalQueue.removeItem(ut);
    queue.remove(position);
    if (position < HomeActivity.queueCurrentIndex) {
        HomeActivity.queueCurrentIndex--;
    }
    notifyItemRemoved(position);
    ((HomeActivity) ctx).updateVisualizerRecycler();
    new HomeActivity.SaveQueue().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : HomeActivity(com.sdsmdg.harjot.MusicDNA.activities.HomeActivity) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)

Example 2 with HomeActivity

use of com.sdsmdg.harjot.MusicDNA.activities.HomeActivity in project MusicDNA by harjot-oberai.

the class LocalMusicViewPagerFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ((HomeActivity) getActivity()).onQueryTextChange("");
    isSearchboxVisible = false;
    backBtn = (ImageView) view.findViewById(R.id.local_fragment_back_btn);
    backBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            getActivity().onBackPressed();
        }
    });
    fragTitle = (TextView) view.findViewById(R.id.local_fragment_title);
    if (SplashActivity.tf4 != null)
        fragTitle.setTypeface(SplashActivity.tf4);
    searchBox = (EditText) view.findViewById(R.id.local_fragment_search_box);
    searchBox.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            ((HomeActivity) getActivity()).onQueryTextChange(s.toString());
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    searchIcon = (ImageView) view.findViewById(R.id.local_fragment_search_icon);
    searchIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (isSearchboxVisible) {
                searchBox.setText("");
                searchBox.setVisibility(View.INVISIBLE);
                InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(getActivity().INPUT_METHOD_SERVICE);
                imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
                searchIcon.setImageResource(R.drawable.ic_search);
                fragTitle.setVisibility(View.VISIBLE);
            } else {
                searchBox.setVisibility(View.VISIBLE);
                searchBox.requestFocus();
                InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(getActivity().INPUT_METHOD_SERVICE);
                imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
                searchIcon.setImageResource(R.drawable.ic_cross_white);
                fragTitle.setVisibility(View.INVISIBLE);
            }
            isSearchboxVisible = !isSearchboxVisible;
        }
    });
    viewPager = (ViewPager) view.findViewById(R.id.viewpager);
    tabLayout = (TabLayout) view.findViewById(R.id.tabs);
    tabLayout.setBackgroundColor(Color.parseColor("#111111"));
    tabLayout.setSelectedTabIndicatorColor(HomeActivity.themeColor);
    viewPager.setAdapter(adapter);
    tabLayout.setupWithViewPager(viewPager);
}
Also used : HomeActivity(com.sdsmdg.harjot.MusicDNA.activities.HomeActivity) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) InputMethodManager(android.view.inputmethod.InputMethodManager) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 3 with HomeActivity

use of com.sdsmdg.harjot.MusicDNA.activities.HomeActivity in project MusicDNA by harjot-oberai.

the class CommonUtils method hideKeyboard.

public static void hideKeyboard(Context ctx) {
    View view = ((HomeActivity) ctx).getCurrentFocus();
    if (view != null) {
        InputMethodManager imm = (InputMethodManager) ctx.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }
}
Also used : HomeActivity(com.sdsmdg.harjot.MusicDNA.activities.HomeActivity) InputMethodManager(android.view.inputmethod.InputMethodManager) View(android.view.View)

Example 4 with HomeActivity

use of com.sdsmdg.harjot.MusicDNA.activities.HomeActivity in project MusicDNA by harjot-oberai.

the class QueueRecyclerAdapter method onItemMove.

@Override
public void onItemMove(int fromPosition, int toPosition) {
    UnifiedTrack prev = queue.remove(fromPosition);
    queue.add(toPosition, prev);
    notifyItemMoved(fromPosition, toPosition);
    if (fromPosition == HomeActivity.queueCurrentIndex) {
        HomeActivity.queueCurrentIndex = toPosition;
    } else if (fromPosition > HomeActivity.queueCurrentIndex && toPosition == HomeActivity.queueCurrentIndex) {
        HomeActivity.queueCurrentIndex++;
    } else if (fromPosition < HomeActivity.queueCurrentIndex && toPosition == HomeActivity.queueCurrentIndex) {
        HomeActivity.queueCurrentIndex--;
    }
    ((HomeActivity) ctx).updateVisualizerRecycler();
    new HomeActivity.SaveQueue().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : HomeActivity(com.sdsmdg.harjot.MusicDNA.activities.HomeActivity) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)

Aggregations

HomeActivity (com.sdsmdg.harjot.MusicDNA.activities.HomeActivity)4 View (android.view.View)2 InputMethodManager (android.view.inputmethod.InputMethodManager)2 UnifiedTrack (com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)2 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1