Xiaomi Open source File Manager micodefileexplorer-Source Research (3)-2 single-instance tool classes

Source: Internet
Author: User

Starting with this article, we'll explain the classes in the Net.micode.fileexplorer.util Toolkit.
The class under this package, functions are also relatively single and independent. Many of the ideas and implementations of code can be used in many environments such as Javaweb and Android.


One, single instance activity manager Activitiesmanager
A single-instance activity manager, "Sodom", from the point of view of the method being called.
Registeractivity registered activity method is used, and getactivity is not used, feel obviously there is a problem ah ~
My current guess:
When you look at a file, you'll create a new activity and register it for preservation.
Then, when needed, use getactivity to get it, then do the follow-up process.
However, the Getactivity method is not used at all.


I guess: "Community open source" is castrated, the code is cut?


Package Net.micode.fileexplorer.util;import Java.util.hashmap;import android.app.activity;/** Single Instance activity manager */public    Class Activitiesmanager {public static final String Activity_file_view = "FileView";    @Deprecated is not used by any other class public static final String activity_file_category = "Filecategory";    @Deprecated is not used by any other class public static final String Activity_tab = "Fileexplorertab";    private static Activitiesmanager instance;    Private hashmap<string, activity> activities = new hashmap<string, activity> (); Private Activitiesmanager () {}//return True indicates successful, False indicates the name exists//There is no return value at all    Say "Community open source" is castrated? is used by fileviewactivity, presumably when viewing a file, a new active public void registeractivity (String name, activity a) {ACTIVITIES.P    UT (name, a);    }//@Deprecated is not being used by any other class public Activity getactivity (String name) {return activities.get (name); } public static Activitiesmanager getinstance () {if (instance = = NULL) instance = new Activitiesmanager ();    return instance; }}




Second, single-instance Setup tool class settings
For 1 functions, Save and view "show hidden files and parent directories".
Are there too few settings or "preferences" for this program?


Package net.micode.fileexplorer.util;/** Single Instance Setup Tool class, save 1 options, whether to show hidden files and parent directories "." */public class Settings {    //whether show system and cache images, default not    private Boolean mshowdotandhiddenfi Les;    private static Settings minstance;    Private Settings () {    } public    static Settings instance () {        if (minstance = = null) {            minstance = new Setting S ();        }        return minstance;    }    public Boolean getshowdotandhiddenfiles () {        return mshowdotandhiddenfiles;    }    public void Setshowdotandhiddenfiles (Boolean s) {        mshowdotandhiddenfiles = s;    }}




Iii. about Single Instance
A class that establishes only one instance.
Currently, none of these 2 classes are thread-safe.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Xiaomi Open source File Manager micodefileexplorer-Source Research (3)-2 single-instance tool classes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.