Beispiel #1
0
 // 初始化运行程序所需要的文件
 public static boolean WriteImageFile(String url, Bitmap bitmap) {
   if (!T.checkSDCard()) return false;
   String sdroot = android.os.Environment.getExternalStorageDirectory().getAbsolutePath();
   String path = "" + sdroot + imgPath;
   String szFileName = URL2FileName(url);
   File file;
   try {
     new File(path).mkdirs();
     path += szFileName;
     file = new File(path);
     if (file.exists()) {
       // return false;
       file.delete();
     }
     file.createNewFile();
     // Finally compress the bitmap, saving to the file
     // previously
     // created
     bitmap.compress(CompressFormat.PNG, 100, new FileOutputStream(file));
     // copyFile(is,path);
     return true;
   } catch (Exception e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     file = new File(path);
     file.delete();
     return false;
   }
 }
Beispiel #2
0
 // 初始化运行程序所需要的文件
 public static Drawable ReadImageFile(String url) {
   if (!T.checkSDCard()) return null;
   String sdroot = android.os.Environment.getExternalStorageDirectory().getAbsolutePath();
   String path = "" + sdroot + imgPath;
   String szFileName = URL2FileName(url);
   File file;
   try {
     new File(path).mkdirs();
     path += szFileName;
     file = new File(path);
     if (file.exists()) {
       return Drawable.createFromPath(path);
     }
   } catch (Exception e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     file = new File(path);
     file.delete();
   }
   return null;
 }
Beispiel #3
0
 // 初始化运行程序所需要的文件
 public static boolean WriteSDLogoFile(Context context, String url, Bitmap bitmap) {
   if (!T.checkSDCard()) return false;
   String sdroot = android.os.Environment.getExternalStorageDirectory().getAbsolutePath();
   String path = "" + sdroot + logoPath;
   String szFileName = URL2FileName(url);
   File file;
   try {
     new File(path).mkdirs();
     path += szFileName;
     file = new File(path);
     if (file.exists()) {
       // return false;
       file.delete();
     }
     file.createNewFile();
     bitmap.compress(CompressFormat.PNG, 100, new FileOutputStream(file));
     return true;
   } catch (Exception e) {
     e.printStackTrace();
     file = new File(path);
     file.delete();
     return false;
   }
 }
Beispiel #4
0
  public void onCreate() {
    setContentView(R.layout.kmain);
    lvTabs = (View) findViewById(R.id.lvTabs);
    btLocal = findViewById(R.id.tab_local);
    // btRemote = findViewById(R.id.tab_network);
    btApps = findViewById(R.id.tab_apps);
    btFavorite = findViewById(R.id.tab_Favorite);
    // btFavorite.setVisibility(View.GONE);
    btTask = findViewById(R.id.tab_task);
    btTask.setVisibility(View.GONE);
    btTools = findViewById(R.id.tab_tools);
    btLocal.setOnClickListener(toolsOnClickListener);
    // btRemote.setOnClickListener(toolsOnClickListener);
    btFavorite.setOnClickListener(toolsOnClickListener);
    btApps.setOnClickListener(toolsOnClickListener);
    btTask.setOnClickListener(toolsOnClickListener);
    btTools.setOnClickListener(toolsOnClickListener);

    myViewPager = (ViewPager) findViewById(R.id.viewpagerLayout);

    m_localPage = new LocalPage(m_act);
    // m_RemotePage = new NetworkPage(m_act);
    m_FavoritePage = new FavoritePage(m_act);
    m_AppsPage = new AppsPage(m_act);
    //		m_TaskPage = new TaskPage(m_act);
    m_ToolsPage = new NetworkPage(m_act);
    m_SearchPage = new SearchResultPage(m_act);

    myViewPager.setAdapter(mAbsPageAdapter);
    mListViews = new ArrayList<AbsPage>();

    mListViews.add(m_SearchPage);
    mListViews.add(m_localPage);
    // mListViews.add(m_RemotePage);
    mListViews.add(m_FavoritePage);
    mListViews.add(m_AppsPage);
    //		mListViews.add(m_TaskPage);
    mListViews.add(m_ToolsPage);
    SwitchPage(Local);

    myViewPager.setOnPageChangeListener(
        new OnPageChangeListener() {

          public void onPageSelected(int arg0) {
            // P.v("king", "onPageSelected - " + arg0);
            // activity从1到2滑动,2被加载后掉用此方法
            // View v = mListViews.get(arg0);
            SwitchPage(arg0);
          }

          public void onPageScrolled(int arg0, float arg1, int arg2) {
            // P.v("king", "onPageScrolled:arg0=" + arg0);//+",arg1=" +
            // arg1+",arg2=" + arg2);
            // 从1到2滑动,在1滑动前调用
          }

          public void onPageScrollStateChanged(int arg0) {
            // P.v("king", "onPageScrollStateChanged - " + arg0);
            // 状态有三个0空闲,1是增在滑行中,2目标加载完毕
            /**
             * Indicates that the pager is in an idle, settled state. The current page is fully in
             * view and no animation is in progress.
             */
            // public static final int SCROLL_STATE_IDLE = 0;
            /** Indicates that the pager is currently being dragged by the user. */
            // public static final int SCROLL_STATE_DRAGGING = 1;
            /** Indicates that the pager is in the process of settling to a final position. */
            // public static final int SCROLL_STATE_SETTLING = 2;
          }
        });
    myViewPager.setCurrentItem(Local);
    T.SetScreenOrientation(m_act, Theme.getScreenOrientation());
  }
  public void onCreate() {
    setContentView(R.layout.searchresultpage);
    super.onCreate();
    final View lySearchMode = findViewById(R.id.lySearchMode);
    tvSearchNotify = (TextView) findViewById(R.id.tvSearchNotify);
    etValue = (EditText) findViewById(R.id.etSearchFileName);
    etValue.setOnFocusChangeListener(
        new OnFocusChangeListener() {
          @Override
          public void onFocusChange(View v, boolean hasFocus) {
            lySearchMode.setVisibility(View.GONE);
          }
        });
    etValue.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {

          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            lySearchMode.setVisibility(View.GONE);
            return false;
          }
        });
    btSearchMode = (Button) findViewById(R.id.btSearchMode);
    btSearchMode.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            if (lySearchMode.getVisibility() == View.GONE) {
              lySearchMode.setVisibility(View.VISIBLE);
            } else {
              lySearchMode.setVisibility(View.GONE);
            }
          }
        });
    btSearch = (Button) findViewById(R.id.btSearch);
    btSearch.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            if (etValue.length() > 0) {
              mFileListFilter.clear();
              fileAdapter.notifyDataSetChanged();
              btSearch.setEnabled(false);
              T.hideInputPad(etValue);
              param.setCaseSensitive(false);
              param.setPath(FileManager.getInstance().getCurrentPath());
              param.setHide(false);
              param.setSearchValue(etValue.getText().toString());
              param.setSubdirectory(true);
              SysEng.getInstance()
                  .addThreadEvent(
                      new LoadSearchFileEvent(v.getContext(), true, param, SearchResultPage.this));
            } else {
              Toast.makeText(m_act, "请输入要查询文件的名称", Toast.LENGTH_LONG).show();
            }
          }
        });

    Button btOptions = (Button) findViewById(R.id.btOptions);
    btOptions.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            new SearchFileDialog()
                .Show(
                    m_act,
                    FileManager.getInstance().getCurrentPath(),
                    param,
                    SearchResultPage.this);
          }
        });

    btnBack = (Button) findViewById(R.id.btBack);
    btnBack.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            backKey();
          }
        });

    lvSearchMode = (ListView) findViewById(R.id.lvSearchMode);
    ArrayList<Map<String, String>> data = new ArrayList<Map<String, String>>();
    HashMap<String, String> item;

    item = new HashMap<String, String>();
    item.put("Title", "搜索全部");
    data.add(item);

    item = new HashMap<String, String>();
    item.put("Title", "搜索音乐");
    data.add(item);
    item = new HashMap<String, String>();
    item.put("Title", "搜索视频");
    data.add(item);
    item = new HashMap<String, String>();
    item.put("Title", "搜索图片");
    data.add(item);
    item = new HashMap<String, String>();
    item.put("Title", "搜索文档");
    data.add(item);
    item = new HashMap<String, String>();
    item.put("Title", "搜索安装包");
    data.add(item);
    item = new HashMap<String, String>();
    item.put("Title", "搜索压缩包");
    data.add(item);

    final SimpleAdapter modeAdapter =
        new SimpleAdapter(
            getContext(),
            data,
            R.layout.listitem_searchmode,
            new String[] {"Title"},
            new int[] {R.id.tvTitle});

    lvSearchMode.setAdapter(modeAdapter);
    lvSearchMode.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Map<String, String> item = (Map<String, String>) modeAdapter.getItem(position);
            btSearchMode.setText(item.get("Title").substring(2));
            param.setSearchType(position);
            lySearchMode.setVisibility(View.GONE);
            ResultFilter();
          }
        });

    lySearchMode.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            lySearchMode.setVisibility(View.GONE);
          }
        });

    m_locallist = (ListView) findViewById(R.id.lvLocallist);
    fileAdapter = new FavorFileAdapter(m_act, 1, mFileListFilter);
    m_locallist.setAdapter(fileAdapter);
    m_locallist.setOnScrollListener(m_localOnScrollListener);
    m_locallist.setOnItemClickListener(this);
    // if (mFileList.size() == 0)
    // {
    // new SearchFileDialog().Show(m_act, FileManager.GetHandler()
    // .getCurrentPath(), param, this);
    // }

    String FileName = m_act.getString(R.string.FavoriteType);
    String Data = new String(T.ReadResourceAssetsFile(m_act, FileName));
    FavoriteGroupParser mFavoriteParser = new FavoriteGroupParser();
    mGroupList.clear();
    ArrayList<FGroupInfo> result = mFavoriteParser.parseJokeByData(m_act, Data);
    mGroupList.addAll(result);

    Button btButton = (Button) findViewById(R.id.btCopy);
    btButton.setOnClickListener(this);

    btButton = (Button) findViewById(R.id.btCut);
    btButton.setOnClickListener(this);

    btButton = (Button) findViewById(R.id.btDelete);
    btButton.setOnClickListener(this);

    btButton = (Button) findViewById(R.id.btPaste);
    btButton.setOnClickListener(this);

    btButton = (Button) findViewById(R.id.btSelectAll);
    btButton.setOnClickListener(this);
  }