Android Open Source - dttv-android Main Activity






From Project

Back to project page dttv-android.

License

The source code is released under:

GNU General Public License

If you think the Android project dttv-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package dttv.app;
/*from w  ww  .  j  a  v  a2s.c  o m*/


import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.text.TextUtils;
import android.view.ContextMenu;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.SearchView;
import android.widget.SearchView.OnQueryTextListener;
import android.widget.SearchView.OnSuggestionListener;
//import android.view.Window;
//import android.view.WindowManager;
import android.widget.Toast;



import dttv.app.impl.I_KeyIntercept;
import dttv.app.utils.Constant;
import dttv.app.widget.SlideTabsFragment;
import dttv.app.widget.SlideTabsFragment.ChangeActionModeListener;

@SuppressLint("NewApi")
public class MainActivity extends FragmentActivity implements OnSuggestionListener,OnQueryTextListener, ChangeActionModeListener,I_KeyIntercept{
  
  final String TAG = "ActionBarViewpager";
  private int CURRENTACTION = Constant.LOCAL_FILE;
  SlideTabsFragment slideFragment;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);  
    /*getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    requestWindowFeature(Window.FEATURE_NO_TITLE);*/
    setContentView(R.layout.activity_main);
    fillFragment();
  }
  
  private void fillFragment(){
    slideFragment = new SlideTabsFragment(this, this);
    FragmentManager fragmentManager = getSupportFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.dt_main_content_frame, slideFragment).commit();
  }

  protected void createActionMode(int mode, Menu menu){
    menu.clear();
    switch(mode){
    case Constant.LOCAL_VIDEO:
      SearchView searchView = new SearchView(this);
      searchView.setMaxWidth(600);
      searchView.setQueryHint("input words");
      searchView.setOnQueryTextListener(this);
      searchView.setOnSuggestionListener(this);
      
      /*menu.add("Search").setIcon(R.drawable.dt_action_search_icon)
      .setActionView(searchView)
      .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);*/
      menu.add("Refresh").setIcon(R.drawable.dt_action_refresh_icon)
      .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM );
      
      menu.add("Setting").setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT);
      break;
    case Constant.LOCAL_AUDIO:
      menu.add("Plus").setIcon(R.drawable.dt_action_plus_icon)
      .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
      menu.add("Setting").setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT);
      break;
    case Constant.LOCAL_FILE:
      menu.add("Refresh").setIcon(R.drawable.dt_action_refresh_icon)
      .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
      menu.add("Setting").setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT);
      break;
    }
  }
  
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    // TODO Auto-generated method stub
    /*if(isNeedInterceptKey){
      return true;
    }*/
    if(keyCode==KeyEvent.KEYCODE_BACK && isNeedInterceptKey){
      slideFragment.myOnKeyDown(keyCode);
      return true;
    }
    return super.onKeyDown(keyCode, event);
  }
  
  /*@Override
  public void onBackPressed() {
    // TODO Auto-generated method stub
    if(isNeedInterceptKey){
    }else{
      super.onBackPressed();
    }
    isNeedInterceptKey = false;
  }*/
  
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v,
      ContextMenuInfo menuInfo) {
    // TODO Auto-generated method stub
    //createActionMode(CURRENTACTION,menu);
    super.onCreateContextMenu(menu, v, menuInfo);
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // TODO Auto-generated method stub
    createActionMode(CURRENTACTION,menu);
    return super.onCreateOptionsMenu(menu);
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // TODO Auto-generated method stub
    String res = item.getTitleCondensed().toString();
    //Toast.makeText(this, res, 1).show();
    if(!TextUtils.isEmpty(res) && res.equals("Setting")){
      openSettingUI();
    }
    return super.onOptionsItemSelected(item);
  }
  
  public void openSettingUI(){
    startActivity(new Intent(this,SettingActivity.class));
  }

  @Override
  public boolean onSuggestionSelect(int position) {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public boolean onSuggestionClick(int position) {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public boolean onQueryTextSubmit(String query) {
    Toast.makeText(this, "You searched for: " + query, Toast.LENGTH_LONG).show();
    return true;
  }

  @Override
  protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    /*if(slideFragment.getView() != null)
      slideFragment.getView().requestFocus();*/
  }
  
  @Override
  public boolean onQueryTextChange(String newText) {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public void changeActionMode(int mode) {
    // TODO Auto-generated method stub
    CURRENTACTION = mode;
    if(CURRENTACTION == Constant.LOCAL_FILE){
      isNeedInterceptKey = true;
    }else{
      isNeedInterceptKey = false;
    }
    invalidateOptionsMenu();
  }
  private boolean isNeedInterceptKey;
  @Override
  public boolean isNeedIntercept(boolean isNeed) {
    // TODO Auto-generated method stub
    Toast.makeText(this, "enter isNeedIntercept", 1).show();
    isNeedInterceptKey = isNeed;
    return isNeed;
  }
  
  
}




Java Source Code List

dttv.app.DtPlayer.java
dttv.app.FileBrowserActivity.java
dttv.app.FileShowActivity.java
dttv.app.IndexActivity.java
dttv.app.MainActivity.java
dttv.app.SettingActivity.java
dttv.app.VideoPlayerActivity.java
dttv.app.adapter.FileAdapter.java
dttv.app.compnent.Compnent.java
dttv.app.compnent.MethodPlayerCompnent.java
dttv.app.compnent.PopWindowCompnent.java
dttv.app.impl.ICallBack.java
dttv.app.impl.I_Async.java
dttv.app.impl.I_KeyIntercept.java
dttv.app.impl.I_OnMyKey.java
dttv.app.impl.I_PopWindow.java
dttv.app.model.Item.java
dttv.app.multithread.DataAsyncTask.java
dttv.app.utils.Constant.java
dttv.app.utils.ControlLightness.java
dttv.app.utils.FileUtil.java
dttv.app.utils.Log.java
dttv.app.utils.MultiMediaTypeUtil.java
dttv.app.utils.MusicUtils.java
dttv.app.utils.PlayerUtil.java
dttv.app.utils.SettingUtil.java
dttv.app.utils.TimesUtil.java
dttv.app.utils.VolumeUtil.java
dttv.app.view.SimpleDialog.java
dttv.app.widget.AudioUIFragment.java
dttv.app.widget.EffectWindow.java
dttv.app.widget.FilesUIFragment.java
dttv.app.widget.GlVideoView.java
dttv.app.widget.OnTouchMoveListener.java
dttv.app.widget.SlideTabsFragment.java
dttv.app.widget.VideoUIFragment.java